Possible Duplicate:
Average performance of binary search algorithm?
http://en.wikipedia.org/wiki/Binary_search_algorithm#Average_performance
BinarySearch(int A[], int value, int low, int high)
{
int mid;
if (high < low)
return -1;
mid = (low + high) / 2;
if (A[mid] > value)
return BinarySearch(...
Given a list of words which contains the letters a-z at least once, how would you write a program to find the shortest pangram counted by number of characters (not counting spaces) as a combination of the words?
Since I am not sure whether short answers exist, this is not code golf, but rather just a discussion of how you would approach...
Hi,
I'm trying to implement the Solovoy-Strassen primality test for arbritrary large integers. I will also be writing a bignum (cannot use 3rd party implementation as this is an academic project). I have decided on the following structure for the bignum:
struct {
uint64_t *tab;
int size; // number of limbs
int sign;
}
I will be...
void printScientificNotation(double value, int powerOfTen)
{
if (value >= 1.0 && value < 10.0)
{
System.out.println(value + " x 10^" + powerOfTen);
}
else if (value < 1.0)
{
printScientificNotation(value * 10, powerOfTen - 1);
}
else // value >= 10.0
{
printScientificNotation(value / 10, powerOfTen + 1);
}
}
assuming...
I have two very large strings and I am trying to find out their Longest Common Substring.
One way is using suffix trees (supposed to have a very good complexity, though a complex implementation), and the another is the dynamic programming method (both are mentioned on the Wikipedia page linked above).
Using dynamic programming
The pr...
Hello,
What algorithm I can use for problem like this:
Have a graph positive weighted, i want to know a smallest
possible sum of weights where each node are connected (connected like a network, where each node is a eg. network device).
In this network each node can be connected with other node by some other other nodes in way. But all...
Hello,
I have a directed, positive weighted graph. Each edge have a cost of use.
I have only A money, i want to calculate shortest paths with dijkstra algorithm, but sum of edges costs on route must be less or equal to A.
I want to do this with most smallest Dijstra modification (if I can do it with small modification of Dijkstra). I ...
Hello,
I want to write fastest possible algorithm for 2 number multiplications.
Each number has max digits around 1000000 and is contained in string.
Anyone want to tell about this problem? I searching really speed solution.
...
Hello,
What is fastest algorithm implementing a square root of decimal contained in strings.
This decimal can have 1000000 digits.
Anyone can tell me something about it?
...
Say I have a list of n elements, I know there are n! possible ways to order these elements. What is an algorithm to generate all possible orderings of this list? Example, I have list [a, b, c]. The algorithm would return [[a, b, c], [a, c, b,], [b, a, c], [b, c, a], [c, a, b], [c, b, a]].
I'm reading this here
http://en.wikipedia.org/wi...
I have the following two dimensional array:
static int[,] arr = new int[5, 5]
{
{ 00, 00, 00, 01, 00 },
{ 00, 00, 01, 01, 00 },
{ 00, 00, 01, 01, 00 },
{ 00, 00, 01, 01, 00 },
{ 00, 00, 00, 01, 00 },
};
I have to a implement a method called Hit(int x, int y). When we hit a 0 in the array (i.e. Hit(0, 0), Hit(1, 1...
I receive encoded PDF files regularly. The encoding works like this:
the PDFs can be displayed correctly in Acrobat Reader
select all and copy the test via Acrobat Reader
and paste in a text editor
will show that the content are encoded
so, examples are:
13579 -> 3579;
hello -> jgnnq
it's basically an offset (maybe swap) of ASCII...
Hey everyone.
I have a problem with the rb-trees. according to wikipedia, rb-tree needs to follow the following:
A node is either red or black.
The root is black. (This rule is used in some definitions and not others. Since the root can always be changed from red to black but not necessarily vice-versa this rule has little effect on a...
I want to multiply two numbers, and detect if there was an overflow. What is the simplest way to do that?
...
Hello everyone.
I try to implement an RSA algorithm in a Java program. I am facing the "BadPaddingException : data must start with zero".
Here are the methods used to encrypt and decrypt my data :
public byte[] encrypt(byte[] input) throws Exception
{
Cipher cipher = Cipher.getInstance("RSA/ECB/PKCS1Padding");//
cipher.init(Ci...
Possible Duplicate:
Matching a rotated bitmap to a collage image
Given an image with a large dimension (> 1.000 x 1.000). What is a good approach to find a small image (e.g. 50 x 50) in the big one?
The smaller image can be rotated and differ in the size, but only with a 1:1 ratio.
It's not related to any programming langua...
Hi -
I'm getting JSON-encoded output from another organization's API.
In many cases, the output can be either an array of objects (if there are many) or an object (if there's just one). Right now I'm writing tortured code like this:
if ( is_array($json['candidateList']['candidate'][0]) ) {
foreach ($json['candidateList']['candidat...
I'm working on a program for class that involves solving the Chinese Postman problem. Our assignment only requires us to write a program to solve it for a hard-coded graph but I'm attempting to solve it for the general case on my own.
The part that is giving me trouble is generating the partitions of pairings for the odd vertices.
For...
I'm interested in a function of two word lists, which would return an order agnostic edit distance between them.
That is, the arguments would be two lists of (let's say space delimited) words and return value would be the minimum sum of the edit (or Levenshtein) distances of the words in the lists.
Distance between "cat rat bat" and ...
Reading about how Google solves the translation problem got me thinking. Would it be possible to build a strong chess engine by analysing several million games and determining the best possible move based largely (completely?) on statistics? There are several such chess databases (this is one that has 4.5 million games), and one could po...