algorithm

What algorithm can I implement to speed up some Cellular Automata simulations?

I am writing a ncurses based C.A. simulator for (nearly) any kind of C.A. which uses the Moore or Neumann neighborhoods. With the current (hardcoded and most obvious [running state funcs]) the simulation runs pretty well; until the screen is filled with 'on' (or whatever active) cells. So my question is: Are there any efficient alg...

Markov Chain Text Generation

We were just assigned a new project in my data structures class -- Generating text with markov chains. Overview Given an input text file, we create an initial seed of length n characters. We add that to our output string and choose our next character based on frequency analysis.. This is the cat and there are two dogs. Initial ...

problem expressing collumn in an algorthm

while writing an algorithm dealing with excel data if we want to compare each cell in a row we write foreach row foreach cell in a row jf ( cell.value > 100 ) but if we dont want to compare each cell in the row but only the cells of a particular collumn then do we write like this ? foreach row if ( particular_collumn.cell.valu...

HMAC - Implementation of PHP algorithm in Objective-C

Hi, I have to implement the HMAC MD5 in my iPhone app. The PHP version of the algorithm (implemented server side for verification) is here and I can't modify it (it's an API) function hmac($key, $data) { $b = 64; // byte length for md5 if (strlen($key) > $b) { $key = pack("H*",md5($key)); } $key = str_pad($key, $b, chr(0x00)); ...

How to generate a unique hash for a URL ?

Given these two images from twitter. http://a3.twimg.com/profile_images/130500759/lowres_profilepic.jpg http://a1.twimg.com/profile_images/58079916/lowres_profilepic.jpg I want to download them to local filesystem & store them in a single directory. How shall I overcome name conflicts ? In the example above, I cannot store them as *l...

is there another way of solving this problem ?

i have a list 1 column and 100 rows each with a number the number on each row may not be unique i need to output the unique list of numbers sorted according to their rank , which is less if the number of its repetitions is more. least ranked number i.e 1 is on the top now here is how i am planning to solve this problem first i want to...

computer vision: extracting info about a shape given a contour (e.g. pointy, round...)

Given the 2D contour of a shape in the form of lines and vertices, how can I Extract Information from that? like: Pointy, round, straight line. Shape similarities with a given shape. Code is not necessary, I am more interested in concepts and the names of techniques involved to guide my search.... Thanks in advance. ...

Fast exponentiation implementation

Could someone please point out a site where I can find an algorithm to efficiently calculate integer exponentiation to large powers using C#? eg. I want to calculate 2^60000 or 3^12345 ...

Balance between fast and secure: time sensitive password encryption algorithm

I'm working on a client<>server multiplayer game. The authentication is done on the same server as all game logic etc. This means that my authentication password encryption algorithm can't take too much calculation time as it would delay all the other required actions. If many people would logon at the same time that would cause a notice...

Algorithm for effective connection resource management

Hi, difficult to look this up if it has been asked previously since I don't know the name for it. So here goes: I'm making this server which connects to messaging gateways in order to send msgs. A session with this gateway requires a username/password combo. This way the gateway knows who to bill. Now I could have thousands of message...

Outline searching

IDE: Delphi 1 16-bit (Yeah it's old, no I can't afford a newer version or the hardware needed to run it. Besides I'm just learning Delphi so it serves the purpose fine.) I've loaded a TOutline with names (to represent an address book). They're in sorted order. I want to be able to search the outline. Possible searches: the whole na...

Can anyone line out where I can get a step by step algorithm for viterbi decoder?

I have this Viterbi Decoder function code, which is quite lengthy and there are no comments labeling to help, and I want to try to understand it. So anyone can point me to an easy to understand algorithm? Anyway, here is the code: int viterbiDecode( int nBit, float *p_pm, int *p_sp, int *p_bStore, float *p_hd, int TB, int fc, int lc, ...

Oriented forest TAoCP - Algorithm in python

I try to implement Algorithm O (Oriented forests) from Donald E. Knuth: 'The Art of Computer Programming - Volume 4, Fascile 4, Generating All Trees' on page 24. My Python solution is: def generate_oriented_forest(n): """Algorithm O from Knuth TAoCP, Fascicle 4, p. 25. """ p = range(-1, n) while True: yield p[1:] ...

Algorithm to move messages from inbox to junk folder

Hi, I wonder how sites like yahoomail or gmail move the messages, which we click as spam into the spam folder. As far as I concerned Bayesian analysis algorithm checks the messages, if it is spam based on content, or some other probability. But what algorithm do these sites(yahoomail or gmail) use to migrate the message from one folder ...

Concept Checking change in C++?

I'm porting over some code from one project to another within my company and I encountered a generic "sets_intersect" function that won't compile: template<typename _InputIter1, typename _InputIter2, typename _Compare> bool sets_intersect(_InputIter1 __first1, _InputIter1 __last1, _InputIter2 __first2, _InputIter2 __...

Is Latent Semantic Indexing (LSI) a Statistical Classification algorithm?

Is Latent Semantic Indexing (LSI) a Statistical Classification algorithm? Why or why not? Basically, I'm trying to figure out why the Wikipedia page for Statistical Classification does not mention LSI. I'm just getting into this stuff and I'm trying to see how all the different approaches for classifying something relate to one another...

How do we calculate the filters in Mel-Frequency Cepstrum Coefficients Algorithm?

After calculating the FFT and with the frequency we need to do something like this: http://instruct1.cit.cornell.edu/courses/ece576/FinalProjects/f2008/pae26%5Fjsc59/pae26%5Fjsc59/images/melfilt.png We filter the frequency spectrum with those triangles. I saw that we can use distint ways to calculcate the triangles. I will make the size...

algorithm to search empty cells in minesweeper

hi Guys, Im creating a minesweeper and just wondering what is the best algorithm to search all the empty cells when the user press the empty cell then grow and limit to the border until it reaches the bomb cell. I planning to use recursive search but probably it will slow the process. Thanks. ...

Understanding algorithms for measuring trends

What's the rationale behind the formula used in the hive_trend_mapper.py program of this Hadoop tutorial on calculating Wikipedia trends? There are actually two components: a monthly trend and a daily trend. I'm going to focus on the daily trend, but similar questions apply to the monthly one. In the daily trend, pageviews is an array ...

How to encode latitude/longitude for box search?

I'm developing an application on Google App Engine and needs to find all the points that are in a box. A basic SQL search would be: minlatitude < latitude AND maxlatitude > latitude AND minlongitude < longitude AND maxlongitude > longitude But, this request is both inefficient and forbidden (you cannot use inequality on 2 differe...