algorithm

What's textmate's 'Go to File' fuzzy search algorithm?

Textmate's 'go to file' fuzzy search is really awesome. Wincent's Command-T plugin for vim does something similar and it rocks too. Can someone explain how these work? Is there a general term for the method they use? Edit: I little more detail about what those tools do The tools let you narrow a list of options (in this case file pa...

efficient way to find matches against two strings

I need to find all equal substrings against two strings. I've tried to use suffix tree to lookup substrings and it works fast, but too memory consuming (inappropriate for my task). Any other ideas? ...

Identifying which Algorithm is which and explaining the running times

For a given problem with input size n, Algorithms A,B,C are executed. In terms of running time, one of the algorithms is O(n), one O(nlogn) and one O(n^2). Some measured running times of these algorithms are given below Input Size 512 1024 2048 A 70 ...

Do POSIX lfind()/lsearch() perform better than looping manually?

Do lfind/lsearch perform better than a typical looping solution that checks each item until it matches? Is there any special sauce/reason that these functions exist? ...

In what languages, associative arrays are implemented using redblack tree instead of hashtable?

In wikipedia: http://en.wikipedia.org/wiki/Red-black_tree#Applications_and_related_data_structures red-black tree is a type of self-balancing binary search tree, a data structure used in computing science, typically used to implement associative arrays. Anyone know a language implemented associative array using redblack tre...

Accessing node data through POSIX tdelete()

The manpage for the POSIX binary tree functions includes the following statements: tdelete() returns a pointer to the parent of the item deleted, or NULL if the item was not found. tdelete() frees the memory required for the node in the tree. The user is responsible for freeing the memory for the corresponding data. ...

Help with Diamond Square algorithm implementation

I'm trying to implement the Diamond-square algorithm, but the problem is only part of the bitmap is being filled and I'm not sure what's wrong. I'm doing it recursively: GLuint CreateDsquare() { std::vector<GLubyte> pdata(256 * 256 * 4); vector2i loc; vector2i sz; GLubyte val; sz.x = 25...

Sliding window searching algorithm

Hi I am in need of a data storage type and algorithm for keeping track of the status of the last N items I have seen. Each item has a status of Pass or Fail, but the system I am monitoring will deemed to have failed if M items in a row have failed. Once the system is deemed to have failed I then need to scan back through the history of...

Culling techniques for rendering lots of cubes

I am working on a personal learning project to make a Minecraft clone. It is working very well aside from one thing. Similar to Minecraft, my terrain has lots of cubes stacked on the Y so you can dig down. Although I do frustum culling, this still means that I uselessly draw all the layers of cubes below me. The cubes are X, Y and Z orde...

Very fast 3D distance check?

Is there a way to do a quick and dirty 3D distance check where the results are rough, but it is very very fast? I need to do depth sorting and im using stl sort like this: bool sortfunc(CBox* a, CBox* b) { return a->Get3dDistance(Player.center,a->center) < b->Get3dDistance(Player.center,b->center); } flo...

Time Aware Social Graph DS/Queries

Classic social networks can be represented as a graph/matrix. With a graph/matrix one can easily compute shortest path between 2 participants reachability from A -> B general statistics (reciprocity, avg connectivity, etc) etc Is there an ideal data structure (or a modification to graph/matrix) that enables easy computation of the ...

Tournament algorithm in php

I need some help. I want to create one tournament. Let's say I have 6 players. 1 2 3 4 5 6 I want to create some.. lets' say stages... Every player will play 5 matches(number of players - 1), in 5 different stages. In one stage, all the players must appear only once. For example, with 6 players I want to generate these results: Squad ...

determining state space based on area

Hi all, I have been tasked with figuring out a state space for a problem based on the area of a rectangle. It seems that I have made my state space far too large and need some feedback. So far I have an area that has a value fo 600 for a y axis and 300 for an x axis. I determined the number of points to be (600 x 300) ! or 1...

In practice, whats the better choice: hash table, radix tree, red black tree or ...?

Hi all, Did you make some experiences with these structures mentioned above? If the insertion and lookup matters, then what seems to be best in practice? If the hash table has lots of collisions, you'd end up with a bucket list you need to traverse, so basically you could end up in O(n) if performance matters. I've made no experiences ...

Finding the maximum area in given binary data...

I have a problem with describing algorithm for finding maximum rectangular area of binary data, where 1 occurs k-times more often than 0. Data is always n^2 bits like this: For example data for n = 4 looks like: 1 0 1 0 0 0 1 1 0 1 1 1 1 1 0 1 Value of k can be 1 .. j (k = 1 means, that number of 0 and 1 is equal). For abov...

Generation of uniformly distributed random noise

I've been working on generating Perlin noise for a map generator of mine. The problem I've run into is that the random noise is not distributed normally, and is more likely a normal distribution of kinds. Given two integers X and Y, and a seed value, I do the following: Use MurmurHash2 to generate a random number (-1,1). This is unifo...

How VIM Autocomplete Work

I was going over VIM shortcuts & found the CTRL+p which acts as an autocomplete in UNIX (you know what I am saying, a dropdown list of the possible words to use, sorted by frequency of usage). It seems to detect even the most immediately typed words. How does this work in VIM? I am specifically interested in the data structures that are ...

What is the fastest algorithm to calculate the minimum distance between two sets of points?

I wanna find the minimum distance between two polygon. I mean, I have to find the minimum of shortest distance between each vertex of first shape with the all the vertexes of the other one. Something like Hausdorff Distance but I need minimum instead of maximum. I appreciate any suggestion. Thank you. ...

Return statement that works but doesn't make much sense

I have the following function: int mult(int y, int z) { if (z == 0) return 0; else if (z % 2 == 1) return mult(2 * y, z / 2) + y; else return mult(2 * y, z / 2); } What I need to do is prove its correctness by induction. Now the trouble I'm having is that even though I know it works since I ran it I can't follow eac...

Pseudocode interpreter?

Like lots of you guys on SO, I often write in several languages. And when it comes to planning stuff, (or even answering some SO questions), I actually think and write in some unspecified hybrid language. Although I used to be taught to do this using flow diagrams or UML-like diagrams, in retrospect, I find "my" pseudocode language has c...