[algogeeks] Re: algorithm

2010-07-27 Thread Avik Mitra
Given that the list is in sorted order. Let us assume that the list in the form of an array A[1...n]. Case 1: If n is odd. Then the median is A[(n+1)/2]. Set MEDIAN:=A[(n +1)/2. Case 2: If n is even. Then the median is (A[n/2]+ A[n/2 +1])/2. Set MEDIAN:=(A[n/2]+ A[n/2 +1])/2. Assuming that the

Re: [algogeeks] Re: algorithm

2010-07-27 Thread Shafi Ahmad
/** find the Middle element in the Array without sorting it. * This function uses a modified version of QuickSort, where we * only consider the one half of the array. * This is a recursive function where we look at some section of the array * (Concerned Array) at a time. * * @param low

Re: [algogeeks] Re: algorithm

2010-07-27 Thread Shafi Ahmad
Please ignore my previus mail as there was some typo mistake. /** find the Middle element in the Array without sorting it. * This function uses a modified version of QuickSort, where we * only consider the one half of the array. * This is a recursive function where we look at some section of

[algogeeks] Want to learn the state of the art on the automatic programming of computers by artificial evolution?

2010-07-27 Thread profrp...@googlemail.com
Hi, I'm a co-editor of a special issue of the Journal of Genetic Programming and Evolvable Machines which looks back at past progress and future possibilities in this amazing area of computer science and machine intelligence. Among lots of goodies it includes a review of human competitive results

[algogeeks] Re: Adobe Strings matching Puzzle.

2010-07-27 Thread bujji
Hi Anand, Can you please explain your code? What is the magic number 10 in if(k == 10) { printf(String Matched\n); } in your code? What does while loop do in your code? Can you please write a comment? -Thanks in advance, Bujji #include stdio.h #include

[algogeeks] Sapient Interview Question

2010-07-27 Thread aparichith
A company has many employees each employee is led by only 1 person except for the CEO (who has no boss). The cost to the company of an employee is the sum of his salary plus the cost to the company of all the people led by him. Given is the following structure : Employee

Re: [algogeeks] Re: Merging of Binary trees

2010-07-27 Thread Ashish Goel
i donot think that the link provided is for the same problem, the link provides a solution to balance a tree whereas this problem is to merge two BST without any limitation on the balance factor having said that th balancing the tree itself is an interesting problem and i must say that the

[algogeeks] Tree with default arguments.

2010-07-27 Thread anugrah
I have a TREE class like this. class tree { public: struct node *root; struct node *head; tree() { root=NULL; head=NULL; } void insert(int num); void inorder(node *temp); int depth(node *temp);

[algogeeks] Re: Merging of Binary trees

2010-07-27 Thread vikas kumar
if it is a simple BT then you can simply attach the root to either child ( which is null ) of other tree . just simply go leftmost and then assign root of other tree as left child, as suggested by Gene. On Jul 27, 8:23 am, Gene gene.ress...@gmail.com wrote: You actually only need a singly linked

Re: [algogeeks] Re: Adobe Strings matching Puzzle.

2010-07-27 Thread Anand
It is just an Implementation of KMP string match Algorithm. In the first section, I am find the prefix function π for a pattern which encapsulates knowledge about how the pattern matches against shifts of itself. This information can be used in second section to avoid testing useless shifts for

[algogeeks] Re: Merging of Binary trees

2010-07-27 Thread Gene
Think hard! It's for a slightly different problem, but the same algorithm works fine. It converts an arbitrarily skewed tree to a perfectly balanced tree. So you can just walk the two input trees, deconstruct them into sorted lists (a fully skewed tree is just a list). Merge the two lists into a

[algogeeks] Re: algorithm

2010-07-27 Thread Gene
I think you have confused the statement of this problem. The (in sorted order) comment makes no sense because a median is exactly one number. One number is always sorted. After every stream element is read, you want to be able to get the median of all elements read so far. You're correct that