GATE Exam  >  GATE Questions  >  The preorder traversal of a binary search tre... Start Learning for Free
The preorder traversal of a binary search tree is 15, 10. 12, 11, 20, 18,  16, 19. Which one of the following is the postorder traversal of the tree?
  • a)
    20, 19, 18, 16, 15, 12, 11, 10
  • b)
    10, 11, 12, 15, 16, 18, 19, 20
  • c)
    19, 16, 18, 20, 11, 12, 10, 15
  • d)
    11, 12, 10, 16, 19, 18, 20, 15
Correct answer is option 'D'. Can you explain this answer?
Verified Answer
The preorder traversal of a binary search tree is 15, 10. 12, 11, 20, ...

Postorder: 11, 12, 10, 16, 19, 18, 20, 15
View all questions of this test
Most Upvoted Answer
The preorder traversal of a binary search tree is 15, 10. 12, 11, 20, ...
Given: Preorder traversal of a binary search tree

To find: Postorder traversal of the tree

Approach:

- The first element in the preorder traversal is the root of the tree.
- In a binary search tree, all elements less than the root will be in the left subtree, and all elements greater than the root will be in the right subtree.
- Recursively apply the above steps to find the left and right subtrees of each node until all nodes are processed.
- The postorder traversal of the tree is obtained by visiting the nodes in the following order: left subtree, right subtree, root.

Solution:

- The root of the tree is 15.
- All elements less than 15 belong to the left subtree, and all elements greater than 15 belong to the right subtree.

Left subtree: 10, 12, 11
Right subtree: 20, 18, 16, 19

- The root of the left subtree is 10.
- All elements less than 10 belong to the left subtree, and all elements greater than 10 belong to the right subtree.

Left subtree: None
Right subtree: 12, 11

- The root of the right subtree is 20.
- All elements less than 20 belong to the left subtree, and all elements greater than 20 belong to the right subtree.

Left subtree: 18, 16, 19
Right subtree: None

- The root of the left subtree is 12.
- All elements less than 12 belong to the left subtree, and all elements greater than 12 belong to the right subtree.

Left subtree: 11
Right subtree: None

- The root of the left subtree is 18.
- All elements less than 18 belong to the left subtree, and all elements greater than 18 belong to the right subtree.

Left subtree: 16
Right subtree: 19

- The left and right subtrees of node 16 and 19 are None.

- The left subtree of node 11 is None.

- The left and right subtrees of node 12 are None.

- The left and right subtrees of node 19 are None.

- The left and right subtrees of node 18 are 16 and 19.

- The left and right subtrees of node 10 are 12 and 11.

- The left and right subtrees of node 20 are 18 and None.

- The left and right subtrees of node 15 are 10 and 20.

- The postorder traversal of the tree is obtained by visiting the nodes in the following order: left subtree, right subtree, root.

Therefore, the postorder traversal of the tree is: 11, 12, 10, 16, 19, 18, 20, 15.

Hence, option D is the correct answer.
Explore Courses for GATE exam
The preorder traversal of a binary search tree is 15, 10. 12, 11, 20, 18, 16, 19. Which one of the following is the postorder traversal of the tree?a)20, 19, 18, 16, 15, 12, 11, 10b)10, 11, 12, 15, 16, 18, 19, 20c)19, 16, 18, 20, 11, 12, 10, 15d)11, 12, 10, 16, 19, 18, 20, 15Correct answer is option 'D'. Can you explain this answer?
Question Description
The preorder traversal of a binary search tree is 15, 10. 12, 11, 20, 18, 16, 19. Which one of the following is the postorder traversal of the tree?a)20, 19, 18, 16, 15, 12, 11, 10b)10, 11, 12, 15, 16, 18, 19, 20c)19, 16, 18, 20, 11, 12, 10, 15d)11, 12, 10, 16, 19, 18, 20, 15Correct answer is option 'D'. Can you explain this answer? for GATE 2024 is part of GATE preparation. The Question and answers have been prepared according to the GATE exam syllabus. Information about The preorder traversal of a binary search tree is 15, 10. 12, 11, 20, 18, 16, 19. Which one of the following is the postorder traversal of the tree?a)20, 19, 18, 16, 15, 12, 11, 10b)10, 11, 12, 15, 16, 18, 19, 20c)19, 16, 18, 20, 11, 12, 10, 15d)11, 12, 10, 16, 19, 18, 20, 15Correct answer is option 'D'. Can you explain this answer? covers all topics & solutions for GATE 2024 Exam. Find important definitions, questions, meanings, examples, exercises and tests below for The preorder traversal of a binary search tree is 15, 10. 12, 11, 20, 18, 16, 19. Which one of the following is the postorder traversal of the tree?a)20, 19, 18, 16, 15, 12, 11, 10b)10, 11, 12, 15, 16, 18, 19, 20c)19, 16, 18, 20, 11, 12, 10, 15d)11, 12, 10, 16, 19, 18, 20, 15Correct answer is option 'D'. Can you explain this answer?.
Solutions for The preorder traversal of a binary search tree is 15, 10. 12, 11, 20, 18, 16, 19. Which one of the following is the postorder traversal of the tree?a)20, 19, 18, 16, 15, 12, 11, 10b)10, 11, 12, 15, 16, 18, 19, 20c)19, 16, 18, 20, 11, 12, 10, 15d)11, 12, 10, 16, 19, 18, 20, 15Correct answer is option 'D'. Can you explain this answer? in English & in Hindi are available as part of our courses for GATE. Download more important topics, notes, lectures and mock test series for GATE Exam by signing up for free.
Here you can find the meaning of The preorder traversal of a binary search tree is 15, 10. 12, 11, 20, 18, 16, 19. Which one of the following is the postorder traversal of the tree?a)20, 19, 18, 16, 15, 12, 11, 10b)10, 11, 12, 15, 16, 18, 19, 20c)19, 16, 18, 20, 11, 12, 10, 15d)11, 12, 10, 16, 19, 18, 20, 15Correct answer is option 'D'. Can you explain this answer? defined & explained in the simplest way possible. Besides giving the explanation of The preorder traversal of a binary search tree is 15, 10. 12, 11, 20, 18, 16, 19. Which one of the following is the postorder traversal of the tree?a)20, 19, 18, 16, 15, 12, 11, 10b)10, 11, 12, 15, 16, 18, 19, 20c)19, 16, 18, 20, 11, 12, 10, 15d)11, 12, 10, 16, 19, 18, 20, 15Correct answer is option 'D'. Can you explain this answer?, a detailed solution for The preorder traversal of a binary search tree is 15, 10. 12, 11, 20, 18, 16, 19. Which one of the following is the postorder traversal of the tree?a)20, 19, 18, 16, 15, 12, 11, 10b)10, 11, 12, 15, 16, 18, 19, 20c)19, 16, 18, 20, 11, 12, 10, 15d)11, 12, 10, 16, 19, 18, 20, 15Correct answer is option 'D'. Can you explain this answer? has been provided alongside types of The preorder traversal of a binary search tree is 15, 10. 12, 11, 20, 18, 16, 19. Which one of the following is the postorder traversal of the tree?a)20, 19, 18, 16, 15, 12, 11, 10b)10, 11, 12, 15, 16, 18, 19, 20c)19, 16, 18, 20, 11, 12, 10, 15d)11, 12, 10, 16, 19, 18, 20, 15Correct answer is option 'D'. Can you explain this answer? theory, EduRev gives you an ample number of questions to practice The preorder traversal of a binary search tree is 15, 10. 12, 11, 20, 18, 16, 19. Which one of the following is the postorder traversal of the tree?a)20, 19, 18, 16, 15, 12, 11, 10b)10, 11, 12, 15, 16, 18, 19, 20c)19, 16, 18, 20, 11, 12, 10, 15d)11, 12, 10, 16, 19, 18, 20, 15Correct answer is option 'D'. Can you explain this answer? tests, examples and also practice GATE tests.
Explore Courses for GATE exam
Signup for Free!
Signup to see your scores go up within 7 days! Learn & Practice with 1000+ FREE Notes, Videos & Tests.
10M+ students study on EduRev