Tree-traversal
Question 1 |
If the binary tree in figure is traversed in inorder, then the order in which the nodes will be visited is ______
4, 1, 6, 7, 3, 2, 5, 8 |
Question 1 Explanation:
Inorder traversal is
(Left, Root, Right)
So, the order will be
4, 1, 6, 7, 3, 2, 5, 8
(Left, Root, Right)
So, the order will be
4, 1, 6, 7, 3, 2, 5, 8
Question 2 |
Which one of the following binary trees has its inorder and preorder traversals as BCAD and ABCD, respectively?
Question 2 Explanation:
Inorder traversal is,
Left root right.
Preorder traversal is,
Root left right.
Left root right.
Preorder traversal is,
Root left right.