algorithm

Diff and Merge or delta sync

Consider a product where changes a client is making to a text file are broadcast to other clients via a Server. The broadcast happens when the person making changes in the editor presses a button. Other client are connected using a tcp\ip pipe so no polling is required In our current solution each time the button is pressed the entire T...

How should I design my rating system?

I'm building a website where users may register and create shopping guides. I want to award them points for creating shopping guides, adding stores and adding brands. It will also be possible for other users to rate the shopping guide. I'm considering to award the owner of the shopping guide more points, if the guide is rated high. But...

python contour for binary 2D matrix

Hi, I want to calculate a convex hull around a shape in a binary NxM matrix. The convex hull algorithm expects a list of coordinates, so I take numpy.argwhere(im) to have all shape point coordinates. However, most of those points are not contributing to the convex hull (they lie on the inside of the shape). Because convex hull computati...

Shortest distance between points algorithm

Given a set of points on a plane, find the shortest line segment formed by any two of these points. How can I do that? The trivial way is obviously to calculate each distance, but I need another algorithm to compare. ...

Algorithms to find stuff a user would like based on other users likes

I'm thinking of writing an app to classify movies in an HTPC based on what the family members like. I don't know statistics or AI, but the stuff here looks very juicy. I wouldn't know where to start do. Here's what I want to accomplish: Compose a set of samples from each users likes, rating each sample attribute separately. For examp...

What is password hashing?

What does it mean to hash a password? ...

Comparing 5 Integers in least number of comparisons

I have this code and need to make sure that all result variables are equal? long result1 = timer.CalculateElapsedTimeInMinutes(); long result2 = timer.CalculateElapsedTimeInMinutes(); long result3 = timer.CalculateElapsedTimeInMinutes(); long result4 = timer.CalculateElapsedTimeInMinutes(); long result5 = timer.CalculateElapsedTimeInMin...

python image recognition

hi, what I want to do is a image recognition for a simple app: given image (500 x 500) pxs ( 1 color background ) the image will have only 1 geometric figure (triangle or square or smaleyface :) ) of (50x50) pxs. python will do the recognition of the figure and display what geometric figure is. any links? any hints? any API? thxs :) ...

When should I do rehashing of entire hash table?

How do I decide when should I do rehashing of entire hash table? ...

Are there any online algorithms for planarity testing?

I know that planarity testing can be done in O(v) (equivalently O(e), since planar graphs have O(v) edges) time. I wonder if it can be done online in O(1) amortized time as each edge is added (still O(e) time overall). In other words, in a database table representing edges of a graph and subject to a constraint that the represented gra...

Arduino: Lightweight Compression Algorithm to store data in EEPROM

I want to store a shitload of data onto my Arduino whith ATmega168/328 Controller, but unfortunately there's only 256KB / 512KB of EEPROM storage. My idea is to make use of an compression algorithm to strip down the size. But well, my knowledge on compression algorithms is quite low and my search for ready-to-use libraries failed. So,...

Finding the minimum set of properties that describe a referent in a set of entities

Hello. I was wondering if someone could help me get pointers to solve this problem. A link to algorithms would be great, but pointers to papers/info is also good. The problem is as follows. Suppose I have a set E of entities E={car1, car2, bicycle} and a set of properties P ={red, blue, small}. I also have a knowledge base such that red...

Sum on a group not including one of the rows of the detail in a grouping

I have my data set column1 column2 column3 column4 column5 data1 data1 data1 data1 data1 data2 data2 data2 data2 data2 data3 data3 data3 data3 data3 data4 data4 data4 data4 data4 sum sum sum sum sum I have those sums of those columns but I want to show the data 4 in the det...

Finding patterns in these numbers

I am currently working on a project. In this project I have set of data which follows particular algorithm. I have to find the pattern. 1 355138022809833 RUPQ730562P 247001 20578330 70175500 2 355138022809841 RUPQ730563D 247001 72754950 71957850 3 355138023475287 RVSQ831978E 247001 39...

Layout manager for .NET, UI agnostic

I need a simple Layout Manager that is UI agnostic. By this, I mean it should not specify how I want to represent my shapes/controls on the screen. It should just enable me to say: I want shape X here. I want shape Y under shape X. I want shape Z to surround X, and isolate itself from shape Y. I guess it would be nice if it can also gi...

Unique random numbers in an integer array in the C programming language.

How do I fill an integer array with unique values (no duplicates) in C? int vektor[10]; for (i = 0; i < 10; i++) { vektor[i] = rand() % 100 + 1; } //No uniqueness here ...

Why is determining if a function is pure difficult?

I was at the StackOverflow Dev Days convention yesterday, and one of the speakers was talking about Python. He showed a Memoize function, and I asked if there was any way to keep it from being used on a non-pure function. He said no, that's basically impossible, and if someone could figure out a way to do it it would make a great PhD t...

library or algorithm to compute viewable GPS satellites

Does anyone know of a library or algorithm (whether freely or commercially available) to compute viewable GPS satellites for a particular location? Even better, does anyone know of a library or algorithm to compute the footprints of GPS satellites given almanac or ephemeris data? Thanks, Jacob ...

looking for an efficient data structure to do a quick searches

I have a list of elements around 1000. Each element (objects that i read from the file, hence i can arrange them efficiently at the beginning) containing contains 4 variables. So now I am doing the following, which is very inefficient at grand scheme of things: void func(double value1, double value2, double value3) { fooArr[100...

Efficient way of calculating likeness scores of strings when sample size is large?

Let's say that you have a list of 10,000 email addresses, and you'd like to find what some of the closest "neighbors" in this list are - defined as email addresses that are suspiciously close to other email addresses in your list. I'm aware of how to calculate the Levenshtein distance between two strings (thanks to this question), which...