Re: [algogeeks] Re: another google telephone interview question

2010-05-18 Thread CHERUVU JAANU REDDY
Here u r using extra space to store count values.. CHERUVU JAANU REDDY M.Tech in CSIS On Tue, May 18, 2010 at 7:01 PM, Jagadish M wrote: > > On May 18, 8:29 am, Terence wrote: > > How do you maintain the heap? Could you explain in detail for the > >

[algogeeks] Re: another google telephone interview question

2010-05-18 Thread Jagadish M
On May 18, 8:29 am, Terence wrote: > How do you maintain the heap? Could you explain in detail for the > following example: > 1 2 3 3 2 1 1 1 2 3 (n=10, k=3) Basically, in each node we maintain the key and its count. Initially, heap has the first element. 1:1 Search for 2 and insert( since its

Re: [algogeeks] Re: another google telephone interview question

2010-05-18 Thread Rohit Saraf
Heap maintains the word and frequency count On 5/18/10, Terence wrote: > How do you maintain the heap? Could you explain in detail for the > following example: > 1 2 3 3 2 1 1 1 2 3 (n=10, k=3) > > On 2010-5-17 22:38, Jagadish M wrote: >> The best algorithm I can think of is to maintain a heap of

[algogeeks] Median of BST

2010-05-18 Thread dhilip
1)do inorder and reverse inorder traversal 2)They will meet at one point or they will cross each other 3)That point is the median 4)Code for the same. while(true) { //inorder traversal while(count1<=count2 && flag1) { if(root) { push(root); root=root->lptr; } else {

[algogeeks] number calculation

2010-05-18 Thread achala sharma
calculate 3digits before decimal for pow(3+sqrt(5),n) where n value can be upto 20 Please provide suggestions on this. -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to algoge...@googlegroups.com.

Re: [algogeeks] Re: another google telephone interview question

2010-05-18 Thread Terence
How do you maintain the heap? Could you explain in detail for the following example: 1 2 3 3 2 1 1 1 2 3 (n=10, k=3) On 2010-5-17 22:38, Jagadish M wrote: The best algorithm I can think of is to maintain a heap of k elements. Takes O(n log k) time. Is anything told about the values of the keys?

Re: [algogeeks] Re: Yahoo coding round question

2010-05-18 Thread Anurag Sharma
@W Karas Can you please give an example and explain your approach. Anurag Sharma On Tue, May 18, 2010 at 12:17 AM, W Karas wrote: > One (space-intensive) idea: > > Re-represent each string as a set of pairs (character, position of > character). Then sort each set of pairs by character. Then f

[algogeeks] Re: median of a bst

2010-05-18 Thread dhilip
1)do inorder and reverse inorder traversal 2)They will meet at one point or they will cross each other 3)That point is the median 4)Code for the same. while(true) { //inorder traversal while(count1<=count2 && flag1) { if(root) { push(root); root=root->lptr; } else {