Search code examples
data-structuresbinary-treesequencetraversal

Find the inorder traversal from its preorder traversal sequence in binary tree


I've given only a pre-order traversal sequence of a binary tree (e.g. {a, b, d, c, e}) and the task is to find out the in-order sequence from it. Pls pardon me if this is a duplicate question.... thanks


Solution

  • I don't think you can find out the inorder traversal based on just the preorder traversal for a binary tree. As you said for binary search tree, sorting will give you the inorder traversal.