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

2010-05-20 Thread Shachin Sharma
Hi Jagdish, I think your solution looks good. The only thing about extra space to store count can be dealt with like this in my view: 1) Do a scan of numbers and determine the max number. 2) Create a max heap (Root is the largest number so by step 1 we have determined the Root for the heap).

Re: [algogeeks] String Problems

2010-05-20 Thread naga vinod kumar
Use trie data structure ,construct it from given matrix On Thu, May 20, 2010 at 7:23 AM, Mario Ynocente Castro ycma...@gmail.comwrote: I don't think 1014 needs any special algorithm, if we've got an H x W matrix, then we've got (4H+4W-2) strings in which you must look, and you can do this

Re: [algogeeks] Median of BST

2010-05-20 Thread Sathaiah Dontula
@Kaushik, I think you can do using inorder successor also, using this successor you can think of BST as Sorted List. What do you say ? Thanks, Sathaiah On Wed, May 19, 2010 at 11:11 AM, kaushik sur kaushik@gmail.com wrote: @Dhilip Is it tested ? I doubt your code won't work ? @Rohit

Re: [algogeeks] String Problems

2010-05-20 Thread vignesh radhakrishnan
@Marcio, I get your algo now. So a substring match is also a match. I get your approach. Thank you. Any ideas for the second problem? On 20 May 2010 10:45, vignesh radhakrishnan rvignesh1...@gmail.com wrote: @Mario Your estimate of no. of strings, I guess doesn't consider strings of length

Re: [algogeeks] String Problems

2010-05-20 Thread gopinath sikha
I think you have to look at this book Algorithms on Strings, Trees and Sequences: Computer Science and Computational Biology By Dan gusfield. It has wonderful data structure which works really fast for string operations. On Wed, May 19, 2010 at 4:16 PM, vignesh radhakrishnan

Re: [algogeeks] String Problems

2010-05-20 Thread vignesh radhakrishnan
@Mario Your estimate of no. of strings, I guess doesn't consider strings of length less than length H or W. it would order(4H^2+4W^2) approximately. I guess I 've understood it right. correct me if I'm wrong On 20 May 2010 07:23, Mario Ynocente Castro ycma...@gmail.com wrote: I don't think

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

2010-05-20 Thread Piyush Verma
@shachin,when u add value of root in the child of root then for insertion of new element when heap is called(so heapify is called) so now this child becomes root which is not desired.. plzz correct me if i m wrong -- You received this message because you are subscribed to the

Re: [algogeeks] Median of BST

2010-05-20 Thread Piyush Verma
@donthulla plzz write code 4 ur logic -- 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. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For

[algogeeks] Alternative to Morris Traversal

2010-05-20 Thread W Karas
Limited to trees where node key values are unique. Seems to have the advantage of better access locality. But I suspect the average time per node is typically greater than for Morris Traversal. typedef struct Node_ { int val; struct Node_ *left, *right; } Node; extern void

Re: [algogeeks] String Problems

2010-05-20 Thread Mario Ynocente Castro
I was thinking about a substring matching, but if that's not what you need, then you still have the same number of strings, but finding a matching in a string would take quadratic time on the length of the string, instead of linear time. 2010/5/20 vignesh radhakrishnan rvignesh1...@gmail.com