Similarly, for the right subtree, the inorder and postorder lists are, respec-
tively, 7,6,8,5 and 6,7,5,8. Applying the same logic recursively to each of
the subtrees yields the following binary tree:
2
b. There is no such example for =2For =3lists 0,1,2 (inorder)
and 2,0,1 (postorder) provide one.
c. The problem can be solved by a recursive algorithm based on the
following observation: There exists a binary tree with inorder traversal
Algorithm Tree (0
1 −1
0
1 −1)
//Construct recursively the binary tree based on the inorder and postorder
traversal lists
9. We can prove equality =+2,whereand are, respectively,.
the external and internal path lengths in an extended binary tree with
internal nodes by induction on The basis case, for =0, holds because
22