A friend and I were a bit perplexed during a programming discussion today. As an example we created a fictive problem of having a List<int> of n random integers (typically 1.000.000), and wanted to create a function that returned the set of all integers that there were more than one of. Pretty straightforward stuff. We created one linq s...
I am looking for solution for :
Given a array and a number P , find two numbers in array whose product equals P.
Looking for solution better than O(n*2) . I am okay with using extra space or other datastructure .Any help is appreciated ?
...
Hey Guys,
I have to scale down image of any dimension to a fixed dimension of 135x135, most imp thing I have to maintain good quality of scaled down image. I'm not much familiar with Image Processing algos. Can you guys suggest me any algorithm.
...
Hi,
I was reading about the licensing of software and one question that came to my mind is that "how software detect the change in system time and block themselves if someone changes system time?". Since there is no other reference available(provided we don't have internet connection, otherwise we can use time servers as reference), how...
Assume you have a set of items in an array.
A, B, C, D, E, F, G, H
Using PHP, how would you randomly pair the letters together without pairing them with a duplicate of themselves?
Such as this:
A->pairedLetter = G
B->pairedLetter = C
C->pairedLetter = E
D->pairedLetter = A
E->pairedLetter = B
F->pairedLetter = D
G->pairedLette...
Can anyone please suggest me any pointer to an iterative algorithm for insertion and deletion into a Red-Black Tree? All the algorithms available in .Net/C# are based on recursion, which I can't trust for handling very large number of data (hence large number of recursion depth for insertion/deletion). Does anybody have one based on iter...
I don't have much experience in SQL so I think this is not a dumb question.
I have 2 tables like this.
A .. G are the members of a hierarchy.
Now my requirement is as follows.
I need to filter out the members which
has status = 0 from Members table.
But, If the selected set contains
children which has a parent with
st...
Example :
S1 : abcde
S2: cdef
Answer : cde
...
Hi there
I have a function in my app that uses a lot of resources, and takes time to execute.
This is normal and control, however I often get errors due to GAE limit of 30 secs/request.
My function takes the argument and returns several results one after the other, decreasing the size of the argument (a unicode string)
Summary:
def m...
I'm coding something at the moment where I'm taking a bunch of values over time from a hardware compass. This compass is very accurate and updates very often, with the result that if it jiggles slightly, I end up with the odd value that's wildly inconsistent with its neighbours. I want to smooth those values out.
Having done some readin...
Hi,
What is the best data-structure for doing following operation quickly
Insert
Find.
Thanks
Avinash
...
I'm performing an operation, lets call it CalculateSomeData. CalculateSomeData operates in successive "generations", numbered 1..x. The number of generations in the entire run is fixed by the input parameters to CalculateSomeData and is known a priori. A single generation takes anywhere from 30 minutes to 2 hours to complete. Some of...
I would like a C# algorithm that re-arranges the chars in a string that is dynamic in length. Having trouble finding one and I know there has to be one out there.
The algorithm has to realign elements to form new strings in all possible combinations.
For instance, "cat" would produce the following:
cat cta tca tac act atc
...
I have algorithmic problem. I don't know how to solve it. Maybe someone can help me?
I have objects. Each object has the same features. It could be illustrated in table:
Feature1 Feature2 Feature3 Feature4
Object1 1 0 1 1
Object2 0 0 0 ...
Hi,
I was reading "programming pearls" book and stuck in some place.
The (best) original solution for the problem (finding sub-array with max sum) is:
maxsofar = О
maxendinghere = О
for i = [0. n)
{
maxendinghere = max(maxendinghere + x[i], 0)
maxsofar = max(maxsofar, maxendinghere)
}
Then the problems is changed as foll...
Possible Duplicate:
How do you implement a Did you mean?
I am writing an application where I require functionality similar to Google's "did you mean?" feature used by their search engine:
Is there source code available for such a thing or where can I find articles that would help me to build my own?
...
I'm looking for a diff algorithm that will produce results like SO's edit revisions page. I've more or less just started looking and I'm not opposed to doing it myself but I don't need to reinvent the wheel.
I'll be using C# 4.0. I'll basically have two strings, and old one and a new one. I want to know what has changed in the new ...
You have a list of n integers and you want the x smallest. For example,
x_smallest([1, 2, 5, 4, 3], 3) should return [1, 2, 3].
I'll vote up unique runtimes within reason and will give the green check to the best runtime.
I'll start with O(n * x): Create an array of length x. Iterate through the list x times, each time pulling out th...
Let's say you need to display a graphical representation of how well a baseball team is doing (my software problem is not related to sports but...).
Let say you chose that 25% of a gauge is related to the percentage of batters who hit during the first time at bat.
The next 25% related to the percentage of pitchers on the team who threw ...
I had once known of a way to use logarithms to move from one leaf of a tree to the next "in-order" leaf of a tree. I think it involved taking a position value (rank?) of the "current" leaf and using it as a seed for a fresh traversal from the root down to the new target leaf - all the way using a log function test to determine whether t...