Re: [algogeeks] Re: Linear time Binary tree re-construction

2011-11-28 Thread Nitin Garg
A[1,n,1,n] will give us the solution. On Mon, Nov 28, 2011 at 7:47 PM, Nitin Garg wrote: > Lets say the in-order traversal is O = O1,O2,...On > Pre-order is P = P1,P2,...Pn > > Lets assume that the in-order traversal gives sorted sequence of numbers. > (if not, we can replace Pi by i in our algo

Re: [algogeeks] Re: Linear time Binary tree re-construction

2011-11-28 Thread Nitin Garg
Lets say the in-order traversal is O = O1,O2,...On Pre-order is P = P1,P2,...Pn Lets assume that the in-order traversal gives sorted sequence of numbers. (if not, we can replace Pi by i in our algorithm and replace it to original later on) Observe P1 will be the root. If left subtree is not empt

Re: [algogeeks] Re: Linear time Binary tree re-construction

2011-11-27 Thread bharath sriram
The in-order and pre-order traversal are already given. So, there is no way to do what you are saying if I understand you completely. On Sun, Nov 27, 2011 at 8:19 AM, Ankuj Gupta wrote: > Hint : try with prestoring the preorder traversal element position in > inorder traversal before constructin

[algogeeks] Re: Linear time Binary tree re-construction

2011-11-27 Thread Ankuj Gupta
Hint : try with prestoring the preorder traversal element position in inorder traversal before constructing 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 unsubscri