Suppose that I have a tree to traverse using a Depth First Search, and that my algorithm for traversing it looks something like this:
algorithm search(NODE):
doSomethingWith(NODE)
for each node CHILD connected to NODE:
search(CHILD)
Now in many languages there is a maximum depth to recursion, for example if the depth of recurs...
Are they the same thing?
...
Have/Want List Matching Algorithm
I am implementing an item trading system on a high-traffic site. I have a large number of users that each maintain a HAVE list and a WANT list for a number of specific items. I am looking for an algorithm that will allow me to efficiently suggest trading partners based on your HAVEs and WANTs matched w...
Hi
I am using the YUI Image cropper to, well crop images. I have the cropper all set up ok. I am now setting the cropper's width's and height vars to defined values that fit my website structure.
I have the cropper set up so that a small resized version of the original is shown with the cropper attached to that. Now, my problem is dete...
I've already asked a question about this, yet I'm still confused. I want to convert a recursive function into a stack based function without recursion. Take, for example, the fibonacci function:
algorithm Fibonacci(x):
i = 0
i += Fibonacci(x-1)
i += Fibonacci(x-2)
return i
(Yes I know I didn't put a base case and that recursio...
In alpha, beta pruning algorithm,
I have a class in which a fucntion def getAction(self,gamestate) id defined. I made 2 more function in def getAction
Like:
class BAC:
def you(self,gamestate):
def me(gamestate,depth,alpha, beta):
------
return v
def both(gamestate,depth,alpha, beta):
-------------------
...
I have an application where I have a number of sets. A set might be
{4, 7, 12, 18}
unique numbers and all less than 50.
I then have several data items:
1 {1, 2, 4, 7, 8, 12, 18, 23, 29}
2 {3, 4, 6, 7, 15, 23, 34, 38}
3 {4, 7, 12, 18}
4 {1, 4, 7, 12, 13, 14, 15, 16, 17, 18}
5 {2, 4, 6, 7, 13, 15}
Data items 1, 3 and 4 match the set beca...
Hi guys,
I have been programming for alot of time. Generally i program in some languages like PHP, ASP.net, Java, JavaScript and others. In all languages i have to use alot of if else statments . Like if value= 10 then ... if i review my code then i find alot of if conditions. So i would like to minimise them but how not sure.
one poi...
Actually, this is not specific to SQL, and I doubt "conversation pattern" is the correct name, but I could not think of a better caption.
To simplify, imagine you got a vast stream of ints. The task is to detect an A.{1;max_n}A pattern: An int satisfies the pattern if it is followed by n (> 0) other ints, then the original int again, wh...
I was wondering how does the F# immutable Map perform against the standard Dictionary.
I am writing a count function (for each line lookup increment set) to use on large files with millions of lines and thousands of elements.
What about the memory usage?
Thanks
...
suppose I have a packet of data and that I am sending the data to 10 users. I want to add an attribute to this data, something like a digital signature. Each of the 10 users would have a different "key". When they apply their key to this special signature on the data packet it returns either true or false. However they cannot determine, ...
The Problem
I want to divide a grid (2D array) into random shaped parts (think earth's tectonic plates).
Criteria are:
User inputs grid size (program should scale because this could be very large).
User inputs grid division factor (how many parts).
Grid is a rectangular shaped hex grid, and is capped top and bottom, wrap around ...
For example, I have 4800 and I would like to see all the divisors of this number.
# num = the number you want factors of
def divisors_of(num)
(1..num).collect { |n| [n, num/n] if ((num/n) * n) == num}.compact
end
divisors_of(4800)
=> [[1, 4800], [2, 2400], [3, 1600], [4, 1200], [5, 960], [6, 800], [8, 600], [10, 480], [1...
I have a unique problem of decrypting strings in realtime. It has to be super fast as it is a part of a caching system. As the caching system is a Java system I am looking for anything compatible.
Is there a way of maybe tweaking the code to run super fast. Maybe write some C/C++ or low level code program and interface it with java?
Any...
While this seems like a duplicate of Crypt Kicker Problem, it isn't.
I've solved the problem, but I'm not all together that satisfied with my solution. The problem statement is:
A common but insecure method of encrypting text is to permute the letters of the alphabet. In other words, each letter of the alphabet is consistently replace...
Hi,
Does anybody know (or may point to some source to read about) a method or algorithm to convert a number represented in binary numeral system into the ternary one (my particular case), or universal algorithm for such conversions?
The solution I've already implemented is to convert a number to decimal first and then convert it into r...
If I have a sorted set of data, which I want to store on disk in a way that is optimal for both reading sequentially and doing random lookups on, it seems that a B-Tree (or one of the variants is a good choice ... presuming this data-set does not all fit in RAM).
The question is can a full B-Tree be constructed from a sorted set of data...
Based on user input height, weight, measurements and other data, dynamically generate a person (can produce 3D graphics?, if you can please tell me how to do)
Who can tell the specific technology, if can please tell me some reference material.
...
I have to convert a floating point to 32-bit fixed point in Java .
Not able to understand what is a 32-bit fixed point ?
Can any body help with algorithm ?
...
I have hit a real problem. I need to do some Kmeans clustering for 5 million vectors, each containing about 32 cols.
I tried out Mahout which requires linux and I am on windows, I am restrained from using a Linux OS and any sort of simulator.
Can anyone suggest a KMeans clustering algorithm that is scalable upto 5M vectors and can con...