algorithm

Google similar images algorithm

Does any one have an idea regarding what sort of algorithm might Google be using to find similar images ? ...

Kind share a site which gives upto date algorithms.

Kind share a site which gives upto date algorithms. ...

dijkstra's algorithm - in c++ ?

Hi, for the past four days I am trying to understand the dijkstra's algorithm. But I can't. I have a vector of points. From that I created a cost matrix. But I don't know how to make the dijkstra's algorithm. Sources are available in net, but I am not from Computer science background, So I can't understand them. I am trying to make a f...

Overlapping polygons on 2D plane

i would like to build a dynamic data structure that can hold a list of polygons and return a list of polygons that overlaps a specified rectangle. i looked into bst trees (and quad trees) but these dont seem to work too well when the polygons overlap heavily. any good ideas i should check out before i roll my own nonsense? edit lets ...

Sorting a two-dimensional toroidal array with rotations and swaps

I tried thinking of an algorithm, but couldn't do it. Here is the problem: There are 16 elements, grouped by four types (a, b, c and d). We also have four groups, A, B, C and D. In the initial state, the four groups have four random elements each, eg.: A: c, c, a, d B: b, b, a, a C: b, b, c, c D: d, d, d, a The order of elements in ...

Big-Oh : How can O(n) + O(n) + ... + O(n) be equal to O(n^2)?

Hi, I'm having a hard time understanding the following statements from Algorithms by S. Dasgupta, C.H. Papadimitriou, and U.V. Vazirani - page 24 that they represent the sum of O(n) as O(n2). But my understanding of O(n) is a linear function of n, and it can never be quadratic no matter how many times the linear fucntions are added (for ...

PHP sort an array of array

Hello! I have the folloring array structure: $list = array(); $element1 = array('start' => '10', 'end' => '15'); $element2 = array('start' => '1', 'end' => '5'); $list[] = $element1; $list[] = $element2; Every element in start and end are numeric only. I would like to sort $list by start values. How can I do that effectivly? ...

Post-order Tree Walk without marking node?

I saw a question which is asking designing algorithm for "Post-order Tree Walk without marking node". What does this question mean? ...

Is there anything which can only be achieved by recursion?

I am not sure but I had heard of an algorithm which can only be achieved by recursion. Does anyone know of such thing? ...

Algorithm for filtering collection

I have object Country, which has Areas. Areas has Provinces. Provinces has Cities, and Cities, and Cities has hotels. I want to filter list of regions to have only objects with property userHaveBeenThere set to true(Areas,Provinces,Cities,and hotels. I'm going to bind this list to treeview. The worst part of this algorith situation, ...

Algorithms for biased spawning of items

In my game, I would like to spawn N items, not necessarily at the same time. Some of the items are dependent on what was spawned before (Markov chain-esque), so the probability of spawning two rocket launchers in a row is low, but there's a reasonable probability of spawning a rocket launcher followed by rockets. What would be the most e...

Rotating images wit odd pixel sides length

Hello, what is the best approach of solving this problem: If you have an image whose sides are even for example 48 x 24 you may do this and you are just fine: matrix.translate(-24, -12); matrix.rotate(Math.PI); matrix.translate(24, 12); But if you have an image of size something like 49 x 25, then there is a problem with those odd pi...

Modelling combinatorial optimization? problem

I've been unable to match this problem into some canonical one, and I would like some guides to build/use an algorithm and solve it. Description is as follows: We have some people who want breakfast. Each one may order any number of coffee, juice and toast. We accumulate the order for all the group. InitialOrder = { C1, J1, T1 } wit...

How are bitmap indexes helpful?

Wikipedia gives this example Identifier Gender Bitmaps F M 1 Female 1 0 2 Male 0 1 3 Male 0 1 4 Unspecified 0 0 5 Female 1 0 But I do not understand this. How is this an i...

Polygon in rectangle algorithm?

I have an algorithm which can find if a point is in a given polygon: int CGlEngineFunctions::PointInPoly(int npts, float *xp, float *yp, float x, float y) { int i, j, c = 0; for (i = 0, j = npts-1; i < npts; j = i++) { if ((((yp[i] <= y) && (y < yp[j])) || ((yp[j] <= y) && (y < yp[i]))) && ...

Please help to compare algorithm complexity

Hello, Please, help me to compare complexity of two algorithms. O(N+1000) + O(M*log(M)) O(N*5) + O(2000) N = 100000 M = 100 I can't understand, what should I do with O(...)? Can I leave it? And just do... (N+1000) + (M*log(M)) = 101200 (N*5) + 2000 = 502000 Is it right? Thank you UPDATED I have task and I have two probable so...

Enumerating m-tuples of Integers Subject to Implication Constraints

How do I enumerate all m-tuples of nonnegative integers (a[1],...,a[m]) subject to the following constraints? For each i in {1,...,m}, there is a number n[i] >= 0 such that a[i] <= n[i]. For each ordered pair (i,j) with i,j in {1,...,m}, there are numbers c[i][j], d[i][j] >= 0 such that: if a[i] > c[i][j], then a[j] <= d[i][j]. c[i][...

Need a way to pick a common bit in two bitmasks at random

Imagine two bitmasks, I'll just use 8 bits for simplicity: 01101010 10111011 The 2nd, 4th, and 6th bits are both 1. I want to pick one of those common "on" bits at random. But I want to do this in O(1). The only way I've found to do this so far is pick a random "on" bit in one, then check the other to see if it's also on, then repe...

Match-three puzzle games algorithm

I am trying to write a match-three puzzle game like 'call of Atlantis' myself. The most important algorithm is to find out all possible match-three possibilities. Is there any open source projects that can be referenced? Or any keywords to the algorithm? I am trying to look for a faster algorithm to calculate all possibilities. Thanks. ...

How Do Vector drawing applications do this?

In Illustrator, you can drag a rectangle and it will select all objects in it. It does beyond a bounding box test since it ensures its touching an actual part of the polygon. How does it efficiently do this then? (A C or C++ implementation would be preferable) Thanks ...