Home » Programming & Data Structure » Programming and data structure miscellaneous » Question

Programming and data structure miscellaneous

Programming & Data Structure

  1. The pre-order traversal of a binary search tree is given by 12, 8, 6, 2, 7, 9, 10, 16, 15, 19, 17, 20. Then the postorder traversal of this tree is :
    1. 2, 6, 7, 8, 9, 10, 12, 15, 16, 17, 19, 20
    2. 2, 7, 6, 10, 9, 8, 15, 17, 20, 19, 16, 12
    3. 7, 2, 6, 8, 9, 10, 20, 17, 19, 15, 16, 12
    4. 7, 6, 2, 10, 9, 8, 15, 16, 17, 20, 19, 12
Correct Option: B

For the given pre-order traversal of a binary search tree, Pre order is : (Root, left, Right)
Pre order : 12, 8, 6, 2, 7, 9, 10, 16, 15, 19, 17, 20
In order is : (Left, Root, Right),
So in order of given sequence is : 2, 6, 7, 8, 9, 10, 12, 15, 16, 17, 19, 20.
Then tree will be :

Now, post order is : (Left, Right, Root)
Post order will be, 2, 7, 6, 10, 9, 8, 15, 17, 20, 19, 16, 12
Hence option (b) is correct.



Your comments will be displayed only after manual approval.