# Need Help - Recursive Algorithm

• September 4th, 2012, 09:33 AM
Need Help - Recursive Algorithm
Hi,

Could you please help me with the below algorithm ? I have constructed binary tree, but i am not well versed with the algorithm and also check if the binary tree (attached) is correct .

Given Postorder & Inorder traversals. Construct the binary tree & write recursive algorithm for tree traversals (Consider all three traversals).
Postorder : IHGFEDCBA
Inorder : GHIFEDCBA

Regards,
• September 4th, 2012, 11:17 AM
MrViggy
Re: Need Help - Recursive Algorithm
• September 4th, 2012, 10:59 PM
nuzzle
Re: Need Help - Recursive Algorithm
Quote:

is correct .

It looks right to me.

Postorder has this recursive structure:

Left branch.
Right branch.
Print.

It visits all nodes all way down to I. Then it retracts while printing in reverse order from I and up.

Inorder looks like this:

Left branch.
Print.
Right branch.

It visits the left nodes all way down to G where it prints and continues to the right. Since the nodes below G don't have a left branch they get printed too on the way down to I. Then it retracts while printing all nodes above G in reverse order on the way back up.
• September 5th, 2012, 07:43 AM
Re: Need Help - Recursive Algorithm
Thank you , MrViggy and nuzzle. Would be able to provide me the algorithm, that would be great.

Thanks,