2 2 votes Given a tree of 3 nodes A,B and C, the Inorder Traversal is CAB and the Preorder Traversal is ABC. What is the structure of the tree? Data Structures + – Samujjal Das 798 views answer comment Share Follow Print See all 2 Comments 2 2 Comments reply pC commented Aug 23, 2016 reply Follow flag i think tree is not possible http://algorithms.tutorialhorizon.com/make-a-binary-tree-from-given-inorder-and-preorder-traveral/ 1 1 replyShare Samujjal Das commented Aug 23, 2016 reply Follow flag Thank you 0 0 replyShare Please log in or register to add a comment.
Best answer 3 3 votes You do damage to property of preorder and inorder preoder : Root Left Right Inorder : Left Root Right you gave CAB as inorder means A is root then C is left and then B is right So how in preorder how can B be a left child. So here you are take preorder of one tree and inorder of another tree. Hope u got it Prashant. answered Aug 24, 2016 • selected Aug 24, 2016 by Prashant. Prashant. comment Share Follow See 1 comment 1 1 comment reply Samujjal Das commented Aug 24, 2016 reply Follow flag Yeah I got it. Thanks! 0 0 replyShare Please log in or register to add a comment.