For a given binary tree find maximum binary search sub-tree
For a given binary tree, largest binary search sub-tree should be found. Example: Input: 10 / \ 50 150 / \ / \ 25 75 200 20 / \ / \ / \ / \ 15 35 65 30 120 135 155 250 Output: 50...
For a given binary tree, largest binary search sub-tree should be found. Example: Input: 10 / \ 50 150 / \ / \ 25 75 200 20 / \ / \ / \ / \ 15 35 65 30 120 135 155 250 Output: 50...
Every recursive problem has an iterative solution. Do you agree or not? Justify your answer. can we solve every recursive problem iteratively or not? as we do in the case of merge sort ...
I'm looking for an answer that scales, but for my specific purpose, I have a 48th dimension vector. This could be represented as an array of 48 integers all between 0 and 255. I have a large dictionary of these vectors, approximately 25 thousand of them. I need to be able to take a vector that may or may not be in my database, and qui...
I need to build a system where we have a set of machines produce unique files, lets call them PRODUCERS and a set of machines receive these files which we call CONSUMERS. Any machine from the PRODUCERS can send files to one or more of the CONSUMERS[ based on some hash mechanism]. I need to build a mechanism which ensures that the file de...
Sitation: overview: I have something like this: std::vector<SomeType> values; std::vector<int> indexes; struct Range{ int firstElement;//first element to be used in indexes array int numElements;//number of element to be used from indexed array int minIndex;/*minimum index encountered between firstElement and fir...
I have a daemon thread which wakes up at a specified interval to do some task. Now I need to add two more tasks to the thread & these tasks have their own intervals. Something like After every x seconds do Task1 After every y seconds do Task2 After every z seconds do Task3 So I basically need to come up with a sleep logic to ensure t...
Internally speaking, which algorithm(s) does PHP use to implement the various sort functions it offers? It seems like the usort variants might use a different algorithm than the built in sorts, but I wanted to know. Where would I even find this information? Thanks! ...
Hi All, I am a undergrad student looking for project ideas, well first my idea was to build a application to simulate graph algorithms but my lecturer told me that it would be better if i use graph algorithms for some other simulations. eg: Traffic light I am looking into the areas and applications that use graph algorithms, i would b...
ISGCI lists a lot of graph classes, many of which are recognizable in polynomial time. Is anyone here aware of actual implementations of these algorithms? ...
I need help with making this bit of code faster: UnitBase* Formation::operator[](ushort offset) { UnitBase* unit = 0; if (offset < itsNumFightingUnits) { ushort j = 0; for (ushort i = 0; i < itsNumUnits; ++i) { if (unitSetup[i] == UNIT_ON_FRONT) { if (j == offset) unit = unitFormation[i]; ++j; } } } el...
Hello I'm having some trouble developing an algorithm to determine the minimum of a list of n elements. It's not the case of finding the minimum of an array of length n, that's simple: min = A[0] for i in range(1, len(A)): if min > A[i]: min = A[i] print min But my list contains objects: class Object: def __init__(self, some...
Right now i'm creating polygons with bezier handles. It's working well, except right now I always do something like this: for(float i = 0; i < 1; i += 0.04) { interpolate A, a.handle to B.handle, B at time i } The problem is no matter how short the distance or long the distance between point A and B, it always produces the same amo...
If we have a continuous function f and values a_0 and b_0 such that f(a_0) * f(b_0) <= 0 then we can use one of several algorithms such as Brent's method, the secant method or just the bisection method (See http://en.wikipedia.org/wiki/Category:Root-finding_algorithms for more) to find a zero of f inside the interval [a_0, b_0]. However,...
suppose we have some arbitrary positive number x i want to know if there is method to represent it's inverse in binary or x's inverse is 1/x how express it in binary? e.x x=5 //101 x's inverese is 1/x it's binary form is=? ...
Possible Duplicate: Solution to a recursive problem (code kata) give an algorithm to find all valid permutation of parenthesis for given n for eg : for n=3, O/P should be {}{}{} {{{}}} {{}}{} {}{{}} {{}{}} ...
the formula is pretty complicated. the numerator is num and the denominator is den, in the formula there is a root on the denominator so i have putted den in sqrrt() but sqrrt only accepts doubles #include<stdio.h> #include<conio.h> #include<math.h> #define LEN 11 // for the following set of x and y find r by the formula .. float sum(fl...
Dear reader, I noticed that I'm often in the need of a container class. For example when working on a particle system, I create a container class Particles which has a member vector<Particle*>. Then I call: Particles* my_particles like my_particles->draw(), and in the Particles.draw() I iterator over the vector<Particle*> and call draw...
Most online games arbitrarily form teams. Often times its up to the user, and they'll choose a fast server with a free slot. This behavior produces unfair teams and people rage quit. By tracking a player's statics (or any statics that can be gathered) how can you choose teams that are as fair as possible? ...
int aux; for(int i=0;i<array.Count()-1;i++) { for(int j=i+1;j<array.Count();j++) { if(array[i] > array[j]) { aux = array[j]; array[j] = array[i]; array[i] = aux; } } } ...
I have tried the following approach: First I do edge contraction for all the edges in the given set of edges to form a modified graph. Then I calculate the total number of spanning trees, using the matrix tree theorem, from the modified graph. I want to know if this method is correct and if there are some other better methods. ...