The catch: only comparisons between elements of the list is allowed. For example, suppose we have 1,000,000 chess players, and we are assigned the task of finding the best chess player in the group. We can play one chess player against any other chess player. Now, we want to minimize the maximum number of games any player plays.
If play...
Sure, I can write a function for it in Python or something...but how can I do it in MYSQL?
WHERE title = "heart of darkness" more or less 3 characters...
...
I have tried to write a random number generators
int generate_random_number(int min , int max )/*min and max describe the range*/
{
/* assume range is 1-4 min=1 max=4*/
create an array b[max] and fill with 1,2,3,4;
shuffle the array b /*shuffle is an another function*/
/* shuffle uses Fısher and yates' modern meth...
My girlfriend got this question in an interview, and I liked it so much I thought I'd share it...
Write an algorithm that receives a dictionary (Array of words). The array is sorted lexicographically, but the abc order can be anything. For example, it could be z, y, x, .., c, b, a. Or it could be completely messed up: d, g, w, y, ... It ...
Algorithm for Finding nth smallest/largest element in an array using data strucuture self balancing binary search tree..
Read the post: http://stackoverflow.com/questions/2329171/find-kth-smallest-element-in-a-binary-search-tree-in-optimum-way/2329236#2329236. But the correct answer is not clear, as i am not able to figure out the corre...
Possible Duplicate:
What is the best book for learning about Algorithms?
Can you suggest me a book which include all of algorithms (about computer science).
I want to buy or download algorithm book for studying.
...
Is the running time of the Merge algorithm O(n log k)?
k is the number of lists.
n is the total number of elements in all of the lists (n = n1 + n2 + ... + nk).
algorithm MakingAHalf(List_Of_Lists)
if List_Of_Lists.size() = 1
return the only list in List_Of_Lists
else
split List_Of_Lists into two halfs (Firs...
I'm looking to add basic licensing to my application. I want to take in the user's name as a parameter and return a unique, fixed length code (sort of like MD5)
What are some algorithms that can do this?
Thanks
...
I have two bitmaps, and I want to copy pixels from A to B only when the pixels are inside an area defined by four corners (a quadrangle). Bitmap A and B are the same size and the quadrangle is defined as four {x,y} coordinates in the pixel space of the image.
Worst case scenario I can test the center of each pixel against the quad to se...
Here's the code I wrote for finding the n-th Fibonacci number:
unsigned long long fib(int n)
{
unsigned long long u = 1, v = 1, t;
for(int i=2; i<=n; i++)
{
t = u + v;
u = v;
v = t;
}
return v;
}
While the algorithm runs pretty quickly, the output starts to freak out when n>93. I think/kno...
a coordinate a(xa,ya) dominates b(xb,yb) if ( xa>=xb and ya>=yb)
how can I find all pairs in a set of coordinates in nlgn using divide and conquer?
edit:the number of pairs instead.
...
From the online discussion groups and blogs, I have seen a lot of interview questions are related to handling large scale dataset. I am wondering is there a systematic approach to analyze this type of questions? Or in more specific, is there any data structure or algorithms that can be used to deal with this? Any suggestions are really a...
how would i do this? I am not sure when I would stop the bst search.
...
Is there someone that knows what is the computational cost for this two piece of code?
while(n>2)
n = sqrt(n);
while(n>2)
n = log(n)
...
Possible Duplicate:
finding all numbers less than x in a BST
How would I modify a binary search to find the number of numbers in a sorted array that are less than a certain number?
...
I have a program I am working on but I am having difficulties to implement Tournament Sort and Insertion Sort in Java.
Please if anyone can help.
...
I'm toying around with writing a random map generator, and am not quite sure how to randomly generate realistic landscapes. I'm working with these sorts of local-scale maps, which presents some interesting problems.
One of the simplest cases is the forest:
Sparse Medium Dense
Typical trees 50% 70% 80...
Hi folks,
I have a huge array list which contains 1000 entries out of which one of the entry is "world". And, I have a word "big world". I want to get the word "big world" matched with "world" in the arraylist.
What is the most cost effective way of doing it? I cannot use .contains method of array list, and If I traverse all the 1000 e...
Minimum Set Cover is a question where you must find the minimum number of sets needed to cover every element.
For example, imagine that we have a set of X=array(1,2,3,4,5,6) and 5 another set S, where
S[1]=array(1, 4)
S[2] =array(2, 5)
S[3] =array(3, 6)
S[4] =array(1, 2, 3)
S[5] =array(4, 5, 6)
The problem is to find minimum numb...
I need an algorithm that can do a one-to-one mapping (ie. no collision) of a 32-bit signed integer onto another 32-bit signed integer.
My real concern is enough entropy so that the output of the function appears to be random. Basically I am looking for a cipher similar to XOR Cipher but that can generate more arbitrary-looking outputs. ...