I'm need some help writing an algorithm in C/C++ (Although an language example would suffice). The purpose is a container/array, which allows insertion at any index. However if inserting an element in an index that is not close to an existing index i.e. would cause an large empty space of buckets. Then the array minimising the empty buc...
This question is from an exam I had, and I couldn't solve it and wanted to see what the answer is (this is not homework, as it will not help me in anything but knowledge).
We need to create a data structure for containing elements whose keys are real numbers.
The data structure should have these functions:
Build(S, array): Builds the da...
This problem came up in the real world, but I've translated it into a more generic "textbook-like" formulation. I suspect it is NP, but I'm particularly interested in knowing if it has a name or is well known since I think I can't be the first one to encounter it. ;-)
Imagine there is a potluck party with N guests. Each guest may bring ...
I'm trying to implement an iterative version of Tarjan's strongly connected components (SCCs), reproduced here for your convenience (source: http://en.wikipedia.org/wiki/Tarjan%27s_strongly_connected_components_algorithm).
Input: Graph G = (V, E)
index = 0 // DFS node number counter
S = empty ...
Start with this:
[G|C] * [T] *
Write a program that generates this:
Cat
Cut
Cute
City <-- NOTE: this one is wrong, because City has an "ESS" sound at the start.
Caught
...
Gate
Gotti
Gut
...
Kit
Kite
Kate
Kata
Katie
Another Example, This:
[C] * [T] * [N]
Should produce this:
Cotton
Kitten
Where should I start my research as...
hi guys ,
I have to use this way to generate codes for a URL shortening service
$code = substr(md5(uniqid(rand(), 1)), 3, 5);
but this is always generate a fixed length code (5 in this case) .
what if there is a large number of URLs in the database that can't stand the five symbols here ?
sorry for the bad English.
...
Dear experts,
I have a a mesh, with certain types of elements (e.g. triangular, tetra). For each element I know all its vertices i.e. a triangular 2D element will have 3 vertices v1, v2 and v3 whose x,y,z coords are known.
Question 1
I am looking for an algorithm that will return all the edges... in this case:
edge(v1, v2), edge(v1,...
I have a set of numbers to compare. Let's say that I have to get this comparison from a user. I have a choice of either asking him a question consisting of 2 numbers or 3 numbers of 4 numbers. For instance, I can ask any of the following questions:
Which of the numbers is greater? 2 OR 4
Which of the numbers is greater? 2 OR 3 OR 4 ...
Hello, I've made a lot of random math programs to help me with my homework (synthetic division being the most fun) and now I'm wanting to reverse a radical expression.
For instance, in my handy TI calculator I get
.2360679775
Well, I want to convert that number to it's equivalent irrational expression, which is
sqrt(5)-2
I realiz...
i am looking for a longest common words c# implementation. Most of the samples i have came across are comparing character by character.
in otherwords,
string1 = access
string2 = advised
should return null output from the function
any sample codes?
...
A list of sorted and rotated element is given. Elements are either sorted in ascending or descending order. For example - I've list of sorted elements as follows
10,12,14,16,18,20,51,53,54,59
Now this list is rotated by X number of times and then it looks as follows.
51,53,54,59,10,12,14,16,18,20
If you want to insert an element in...
What algorithm is typically used when implementing a spell checker that is accompanied with word suggestions?
At first I thought it might make sense to check each new word typed (if not found in the dictionary) against it's Levenshtein distance from every other word in the dictionary and returning the top results. However, this seems l...
I have a large array 15x15x2200. THis is merely a collection of 15x15 sparse matrices depicting the links between 15 nodes and how they vary over 2200 time units. I need to calculate for how much time does each link persist. By this I mean, suppose A[4,11] is 0 till time unit 5 and stays 1 till time unit 20 and then becomes 0 and again b...
Hi, in Python I wanting see all the possible combination's of a number, but limiting to 0's and 1's...
So for example the result of some loop would be:
0000
0001
0011
0111
1111
1000
and so on.
What python algorithm would best suite this?
...
I've got a fairly simple pagination algorithm here but it's not working the way I'd like it to.
Currently it's displaying like this
1 2 3 ... 33 34 35 [36] 37 38 ... 47 48 49 50
When it should be displaying like this
1 2 3 ... 33 34 35 [36] 37 38 39 ... 48 49 50
Here's my code, I wrote it very quickly. It also seems to continuous...
I am working on a Computer Vision problem, in which I have to merge regions of an image. A region (or blob) is defined by its lines, i.e. the following region of O:
0123456789
0 XXXXOXXXXX
1 XXXOOOXXXX
2 XXXOOXXXXX
3 XXXOXXXXXX
4 XXXXXXXXXX
is defined by :
row: 0, cols: 4-4
row: 1, cols: 3-5
row: 2, cols: 3-4
row: 3, cols: 3-3
I ...
I have a huge dataset with words word_i and weights weight[i,j],
where weight is the "connection strength" between words.
I'd like to binarize this data, but I want to know if there is any existing algorithm to make binary code of each word in such a way that the Hamming distance between the codes of the words correlates with this weig...
Need a suggestion for an algorithm.
For a given number N i have to find all the prime numbers it's consisting of, like this:
N = 49
49 = 7 ^ 2
N = 168
168 = (2 ^ 3) * (3 ^ 1) * (7 ^ 1)
If you want to help me even more you can write the algo in c++.
Thanks.
...
Suppose you have the following list of numbers, {3,6,10,9,13,16,19}, not necessarily in that order. Now, not knowing that this is the set of the possible combination of the set {3,6,10}, is there an algorithm, in any programming language that can be used to find these combination efficiently.
Basically, I want to recover the list from th...
How is the an encryption algorithm's security dependent on factoring large numbers?
For example, I've read on some math-programming forums that by using the Quadratic Sieve or the General Number Field Sieve, one can factor a 256 bit number with relative ease on commercially available hardware.
How does this translate to being able to b...