[algogeeks] Re: Interview question amazon

2011-01-16 Thread juver++
@mac Path always should be go through the root of the tree? -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to

Re: [algogeeks] Re: Interview question amazon

2011-01-04 Thread juver++
Why??? It doesn't help to solve problem. You are already have tree structure with parent links. Taunt. -- 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

Re: [algogeeks] Re: Interview question amazon

2011-01-03 Thread juver++
Tree structure already have parent node link. Even we reconstruct the tree as linked list we are not allowed to achieve the goal. Path can be combined using non-contigious (created from inorder traversal) elements. The only solution is using DP with O(MAX_SUM_VALUE) extra space for each node.

Re: [algogeeks] Re: Interview question amazon

2011-01-03 Thread rahul patil
On Mon, Jan 3, 2011 at 6:08 PM, juver++ avpostni...@gmail.com wrote: Tree structure already have parent node link. Even we reconstruct the tree as linked list we are not allowed to achieve Normal tree node does not contain link to its parent. I am not saying convert tree into linklist

Re: [algogeeks] Re: Interview question amazon

2011-01-03 Thread rahul patil
On Tue, Jan 4, 2011 at 8:13 AM, rahul patil rahul.deshmukhpa...@gmail.comwrote: On Mon, Jan 3, 2011 at 6:08 PM, juver++ avpostni...@gmail.com wrote: Tree structure already have parent node link. Even we reconstruct the tree as linked list we are not allowed to achieve Normal tree node

Re: [algogeeks] Re: Interview question amazon

2011-01-02 Thread rahul patil
On Sun, Jan 2, 2011 at 8:30 PM, Akash Agrawal akash.agrawa...@gmail.comwrote: I have written a kinda messed-up code for the same. Which is basically a bottom-up approach. Please find the same as attached. Some boundary conditions might be missed and code can be written in a more decorated,

Re: [algogeeks] Re: Interview question amazon

2010-12-31 Thread MAC
No , we had to find all the paths . Some paths could include the root . On Tue, Dec 28, 2010 at 11:12 PM, yq Zhang zhangyunq...@gmail.com wrote: I think the original question says Path can go from left subtree tree , include root and go to right tree as well. This should mean the path must

[algogeeks] Re: Interview question amazon

2010-12-28 Thread master007
There are 3 paths exist in bst, post, pre and inorder. store all these paths and find contiguous sum(and set of elements which leads to this sum) and check if it equals to given sum, then that is path. On Dec 27, 6:48 pm, mohit ranjan shoonya.mo...@gmail.com wrote: any hint for below question

[algogeeks] Re: Interview question amazon

2010-12-28 Thread juver++
Incorrect. Path can be combined from the several traversal algorithm's output. -- 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] Re: Interview question amazon

2010-12-28 Thread shanushaan
Not clear what path you are referring to. Question. Should the path include root value always? (What is problem with only left or only right path (not containing root)) In your example for 16 one more path can be 0 1 5 10 as well. Should algo return all the paths or just first one.

Re: [algogeeks] Re: Interview question amazon

2010-12-28 Thread yq Zhang
I think the original question says Path can go from left subtree tree , include root and go to right tree as well. This should mean the path must include the root. On Tue, Dec 28, 2010 at 4:52 AM, shanushaan er.srivastavaro...@gmail.comwrote: Not clear what path you are referring to.

[algogeeks] Re: Interview question amazon

2010-12-28 Thread suhash
And of course boundary cases(leaf nodes) are to be handled. For a leaf node 'i', ok[i][j]=1(if j==v[i]), 0 otherwise!!! On Dec 28, 11:04 pm, suhash suhash.venkat...@gmail.com wrote: I think this can be solved using dp. Consider the subtree rooted at node 'i'. Let ok[i][j] be a boolean (0 or 1)