algorithm

Heavy computations analysis/optimization

First of all, I don't have multiplication, division operations so i could use shifting/adding, overflow-multiplication, precalculations etc. I'm just comparing one n-bit binary number to another, but according to algorithm the quantity of such operations seems to be huge. Here it is : There is given a sequence of 0's and 1's that is di...

TopCoder algorithm problem - how to make progress on this one?

I've recently joined TopCoder and have been practicing in the Practice Rooms for the last few days. I came across this problem which I cant seem to solve. Any help will be appreciated. The problem The product value of a string is the product of all the digits ('0'-'9') in the string. For example, the product value of "123" is...

Regarding in-place merge in an array

I came across the following question. Given an array of n elements and an integer k where k < n. Elements {a0...ak} and {ak+1...an} are already sorted. Give an algorithm to sort in O(n) time and O(1) space. It does not seem to me like it can be done in O(n) time and O(1) space. The problem really seems to be asking how to do the merge ...

clear all but the two most significant set bits in a word

Given an 32 bit int which is known to have at least 2 bits set, is there a way to efficiently clear all except the 2 most significant set bits? i.e. I want to ensure the output has exactly 2 bits set. What if the input is guaranteed to have only 2 or 3 bits set.? Examples: 0x2040 -> 0x2040 0x0300 -> 0x0300 0x0109 -> 0x0108 0x5040 -> ...

Algorithm and data structure implementations for C programmers

Possible Duplicate: Are there any open source C libraries with common data structures? What is the best source of algorithm and data structure implementations for C programmers? Links to an open source library or a book will do. (Please don't point to Sedgewick, as I already have his book). ...

What is a "tagged DFA"?

I came across a regular expression library http://laurikari.net/tre/ and also http://hackage.haskell.org/package/regex-tdfa , but I could not find anything about this "tagged DFA" approach that they are using: neither on the pages of these libraries, nor in google (incl.scholar). Anyone know what it is about? ...

Help me to make a algorithm to determine the Rank of a Matrix

I want to make a program which will determine the Rank of a given Matrix in C# Console Application. But I cannot able to make the algorithm for that. Can you please help me make that algorithm? ...

C++ - How to work with BIG numbers?

Possible Duplicates: BigInt in C? How to implement big int in C++ How do we work with big numbers without making use of external libraries and functions? Some problems are as follows: What is the sum of the digits of the number 21000? Work out the first ten digits of the sum of the following one-hundred 50-digit numbers. ...

Shunting-yard: missing argument to operator

I'm implementing the shunting-yard algorithm. I'm having trouble detecting when there are missing arguments to operators. The wikipedia entry is very bad on this topic, and their code also crashes for the example below. For instance 3 - (5 + ) is incorrect because the + is missing an argument. Just before the algorithm reaches the ), t...

Sorting Algorithm with paging

Is there any existing sorting algorithms that include paging? For example. What if my records are too large to fit into memory, how would you handle something like that? ...

algorithm design in python

I need to know about the uniform cost search algorithm. In the uniform cost solution, we find a node that has the lowest cost. But there can be other nodes that have less cost than the previous one.Do we need use some buffer to keep the lowest value in that , so that we can get the lowest cost from the whole tree??I need some pseducode ...

Which zlib functions are compatable with WinZip?

Using deflate() I was unable to open the zipped file using WinZip. Are the gz() the only ones compatable with WinZip? or is there some sort of mode I must call deflate() with? Thanks. ...

Smallest bounding quadtree node

I'm writing an integer-based quadtree structure which builds up from the node, and not down. To do this, I need to discover the next largest node which contains all my elements. If I have a preexisting node defined, then try to add an item outside of that node's bounds, it needs to create a larger node to encompass them both. I have (wha...

mat lad algorithms for a potentiostat

please i need a matlab algorithms for a potentiostat thanks ...

Efficient Packing Algorithm for Regular Polygons

I'm looking for a packing algorithm which will reduce a regular polygon into rectangles and right triangles. The algorithm should attempt to use as few such shapes as possible and should be relatively easy to implement (given the difficulty of the challenge). If possible, the answer to this question should explain the general heuristics...

How to use transposition tables with MTD(f)

I'm writing an AI for a card game and after some testing I've discovered that using MTD(f) on my alpha beta algorithm - a series of zero-window searches - is faster than just using alpha-beta by itself. The MTD(f) algorithm is described well here http://people.csail.mit.edu/plaat/mtdf.html The problem I have is that for each pass in th...

Positioning squares on a circle with minimum diameter

Given n squares with edge length l, how can I determine the minimum radius r of the circle so that I can distribute all squares evenly along the perimeter of the circle without them overlapping? (Constraint: the first square will always be positioned at 12 o'clock.) Followup question: how can I place n identical rectangles with height h...

Three-way conditional in c++ to determine sign equivalance of two numbers

I need the most efficient way (in cpu cycles) to determine if two numbers have the same/different sign. But the catch is if either number is zero I need to be able to distinguish it from numbers with same/different signs (ie. zero is treated as a "third" sign). The following code is similar to what I need, but the return values can be an...

Algorithm that converts numeric amount into English words

What is the most efficient way to convert numeric amount into English words e.g. 12 to twelve 127 to one hundred twenty-seven ...

Is there any algorithm for generating 3d clouds?

So Id love to see an algorithm for generating 3d cloud objects. as realistic as possible. I know that there are different cloud types But I am moust interested in such cloud tupes like so can any one point to algorithm or just a C\C++\C#\AS3 or any other language lib that can do such thing? ...