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
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
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
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