algorithm

algorithm to check if a space is convex

is this possible to do in less than polynomial time? ...

Improving my file i/o algorithm

For a given set of text files, I need to find every "\" character and replace it with "\\". This is a Windows system, and my scripting language options are Javascript, VBScript, or Perl. These files are largish (~10MB a piece), and there are a good number of them (~15,000). I've already come up with the following Javascript: function...

How to code a simple versioning system ?

I want to do a simple versioning system but i don't have ideas on how to structure my datas, and my code. Here is a short example: User logs in User has two options when uploading a file: Submit a new file Submit a new version of a file Users should be able to see the tree. (the different version) The tree can only be up to 2 leve...

How does Erlang's support for *transparent* distribution of actors impact application design?

One of the features of the actor model in Erlang is transparent distribution. Unless I'm misinterpreting, when you send messages between actors, you theoretically shouldn't assume that they are in the same process space or even co-located on the same physical machine. I've always been under the impression that distributed, fault tole...

Easiest algorithm of Voronoi diagram to implement?

Hi, What are the easy algorithms to implement Voronoi diagram? I couldn't find any algorithm specially in pseudo form. Please share some links of Voronoi diagram algorithm, tutorial etc. Thanks in advance. ...

Fast Average Square Difference Function

I'm wondering if anyone knows of a fast (i.e. O(N log(N)) ) method of calculating the average square difference function (ASDF) or average magnitude difference function (AMDF) for a periodic signal, or it is even possible. I know that one can use the FFT to calculate the periodic cross correlation. For example, in Matlab code, for i=1:...

Fast Interleaving of Data

I'm working with some piece of hardware (the hardware itself is not important) and I need to split some block data intro separate pieces in order to make the thing run faster. So I have, for example a contiguous block of memory X words long. For visualzation, I'm arranging it into 50 word lines below: 001 002 003 004 005 006 007 ....

Pattern for a back off mechanism in a client server system

I have a system which needs to send requests to an external system, whenever a user does search on my system. If the external system is down or is taking an unusually long time to answer, I would like my system to "back off" for a while. Instead of trying to make more requests to the external system, I want to just let the user of my s...

How do I go about implementing nine man morris game

How do i go about implementing nine man morris game without doing exhaustive search of all the solution space. ...

Calculate median data flow speed?

Hello. I have an OnRecv() function that is randomly called with random chunks of data. Is it any easy way to calculate median speed for last second? It may be near any number of calls per second - from 0-1 to 10000+. Programming language is irrelevant. ...

Algorithm to share/settle expenses among a group

Hi All - I am looking forward for an algorithm for the below problem. Problem: There will be a set of people who owe each other some money or none. Now, I need an algorithm (the best and neat) to settle expense among this group. Person AmtSpent A 400 B 1000 C 100 Total 1500 Now, expense per person is 1500/3 = 500....

Is this "Valid mathematical expression" problem P, or NP?

This question is purely out of curiosity. I am off school for the summer, and was going to implement an algorithm to solve this just for fun. That led to the above question, how hard is this problem? The problem: you are given a list of positive integers, a set of mathematical operators and the equal sign(=). can you create a valid math...

Picking a bounded uniform random value in GF(2^M) without exponentiation or tables

I am looking for a way to uniformly choose values in GF(2^M) between two bounds. GF(2^M) is a Galois Field - See GF(4) as defined on this page - http://www.math.umbc.edu/~campbell/Math413Spr09/Notes/12-13_Finite_Fields.html From a technical, non-math perspective, this is most similar to CRC operations. For example: ulong gf2step...

Data structure for finding nearby keys with similar bitvalues

I have some data, up to a between a million and a billion records, each which is represented by a bitfield, about 64 bits per key. The bits are independent, you can imagine them basically as random bits. If I have a test key and I want to find all values in my data with the same key, a hash table will spit those out very easily, in O(1)...

OpenMp C++ algorithms for min, max, median, average

I was searching Google for a page offering some simple OpenMp algorithms. Probably there is an example to calculate min, max, median, average from a huge data array but I am not capable to find it. At least I would normally try to divide the array into one chunk for each core and do some boundary calculation afterwards to get the result...

Format an array of tuples in a nice "table"

Hi guys, Say I have an array of tuples which look like that: [('url#id1', 'url#predicate1', 'value1'), ('url#id1', 'url#predicate2', 'value2'), ('url#id1', 'url#predicate3', 'value3'), ('url#id2', 'url#predicate1', 'value4'), ('url#id2', 'url#predicate2', 'value5')] I would like be able to return a nice 2D array to be able to display...

Find the lowest unused number

I've setup a std map to map some numbers, at this point I know what numbers I'm mapping from an to, eg: std::map<int, int> myMap; map[1] = 2; map[2] = 4; map[3] = 6; Later however, I want to map some numbers to the lowest number possilbe that is not in the map, eg: map[4] = getLowestFreeNumberToMapTo(map); // I'd like this to return...

How do I find a color that is between two other colors?

I am assigning each color a numeric value. For example: Color.red: 12 Color.Blue: 6 I need to find a color between two colors (for example, red and blue). But how? I have tried this, (Color.red+color.blue)/2=> (12 + 6)/2 = 9 9 corresponds to Color.yellow ...

Convert RGB method?

How can I do this? int blue = Color.Blue.ToArgb(); int yellow = Color.Yellow.ToArgb(); blue = (blue + yellow) / 2; Color Blue = ConvertFromRGB(blue); ...

Where are memory management algorithms used?

There are a set of memory management algorithms used in operating system construction, like pagination, segmentation, paged segmentation (paginación segmentada), segment pagination (segmentación paginada) and others. Do you know if they are used besides that area, in not so low level software? They are used in bussiness applications? ...