GATE Exam  >  GATE Questions  >  The pre-order traversal of a binary search tr... Start Learning for Free
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 post-order traversal of this tree is:
  • a)
    2, 6, 7, 8, 9, 10, 12, 15, 16, 17, 19, 20
  • b)
    2, 7, 6, 10, 9, 8, 15, 17, 20, 19, 16, 12
  • c)
    7, 2, 6, 8, 9, 10, 20, 17, 19, 15, 16, 12
  • d)
    7, 6, 2, 10, 9, 8, 15, 16, 17, 20, 19, 12
Correct answer is option 'B'. Can you explain this answer?
Verified Answer
The pre-order traversal of a binary search tree is given by 12, 8, 6, ...
View all questions of this test
Most Upvoted Answer
The pre-order traversal of a binary search tree is given by 12, 8, 6, ...
Explanation:

  • The first element in the pre-order traversal is the root of the binary search tree. So, the root of this tree is 12.

  • Next, we look for the first element greater than the root, which is 16. All the elements to the left of 16 are in the left sub-tree and all elements to the right of 16 are in the right sub-tree.

  • So, the left sub-tree has the pre-order traversal 8, 6, 2, 7, 9, 10 and the right sub-tree has the pre-order traversal 15, 19, 17, 20.

  • We can now recursively apply this process to the left and right sub-trees to construct the binary search tree.

  • Now, to find the post-order traversal, we need to first find the post-order traversal of the left sub-tree, then the right sub-tree and finally combine them with the root.

  • Applying the same process to the left sub-tree, we get the post-order traversal 2, 7, 6, 10, 9, 8.

  • Similarly, applying the same process to the right sub-tree, we get the post-order traversal 17, 20, 19, 15.

  • Finally, we combine the post-order traversals of the left and right sub-trees with the root to get the overall post-order traversal as 2, 7, 6, 10, 9, 8, 15, 17, 20, 19, 16, 12.

  • Therefore, the correct answer is option 'B'.

Explore Courses for GATE exam
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 post-order traversal of this tree is:a)2, 6, 7, 8, 9, 10, 12, 15, 16, 17, 19, 20b)2, 7, 6, 10, 9, 8, 15, 17, 20, 19, 16, 12c)7, 2, 6, 8, 9, 10, 20, 17, 19, 15, 16, 12d)7, 6, 2, 10, 9, 8, 15, 16, 17, 20, 19, 12Correct answer is option 'B'. Can you explain this answer?
Question Description
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 post-order traversal of this tree is:a)2, 6, 7, 8, 9, 10, 12, 15, 16, 17, 19, 20b)2, 7, 6, 10, 9, 8, 15, 17, 20, 19, 16, 12c)7, 2, 6, 8, 9, 10, 20, 17, 19, 15, 16, 12d)7, 6, 2, 10, 9, 8, 15, 16, 17, 20, 19, 12Correct answer is option 'B'. 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 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 post-order traversal of this tree is:a)2, 6, 7, 8, 9, 10, 12, 15, 16, 17, 19, 20b)2, 7, 6, 10, 9, 8, 15, 17, 20, 19, 16, 12c)7, 2, 6, 8, 9, 10, 20, 17, 19, 15, 16, 12d)7, 6, 2, 10, 9, 8, 15, 16, 17, 20, 19, 12Correct answer is option 'B'. 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 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 post-order traversal of this tree is:a)2, 6, 7, 8, 9, 10, 12, 15, 16, 17, 19, 20b)2, 7, 6, 10, 9, 8, 15, 17, 20, 19, 16, 12c)7, 2, 6, 8, 9, 10, 20, 17, 19, 15, 16, 12d)7, 6, 2, 10, 9, 8, 15, 16, 17, 20, 19, 12Correct answer is option 'B'. Can you explain this answer?.
Solutions for 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 post-order traversal of this tree is:a)2, 6, 7, 8, 9, 10, 12, 15, 16, 17, 19, 20b)2, 7, 6, 10, 9, 8, 15, 17, 20, 19, 16, 12c)7, 2, 6, 8, 9, 10, 20, 17, 19, 15, 16, 12d)7, 6, 2, 10, 9, 8, 15, 16, 17, 20, 19, 12Correct answer is option 'B'. 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 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 post-order traversal of this tree is:a)2, 6, 7, 8, 9, 10, 12, 15, 16, 17, 19, 20b)2, 7, 6, 10, 9, 8, 15, 17, 20, 19, 16, 12c)7, 2, 6, 8, 9, 10, 20, 17, 19, 15, 16, 12d)7, 6, 2, 10, 9, 8, 15, 16, 17, 20, 19, 12Correct answer is option 'B'. Can you explain this answer? defined & explained in the simplest way possible. Besides giving the explanation of 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 post-order traversal of this tree is:a)2, 6, 7, 8, 9, 10, 12, 15, 16, 17, 19, 20b)2, 7, 6, 10, 9, 8, 15, 17, 20, 19, 16, 12c)7, 2, 6, 8, 9, 10, 20, 17, 19, 15, 16, 12d)7, 6, 2, 10, 9, 8, 15, 16, 17, 20, 19, 12Correct answer is option 'B'. Can you explain this answer?, a detailed solution for 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 post-order traversal of this tree is:a)2, 6, 7, 8, 9, 10, 12, 15, 16, 17, 19, 20b)2, 7, 6, 10, 9, 8, 15, 17, 20, 19, 16, 12c)7, 2, 6, 8, 9, 10, 20, 17, 19, 15, 16, 12d)7, 6, 2, 10, 9, 8, 15, 16, 17, 20, 19, 12Correct answer is option 'B'. Can you explain this answer? has been provided alongside types of 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 post-order traversal of this tree is:a)2, 6, 7, 8, 9, 10, 12, 15, 16, 17, 19, 20b)2, 7, 6, 10, 9, 8, 15, 17, 20, 19, 16, 12c)7, 2, 6, 8, 9, 10, 20, 17, 19, 15, 16, 12d)7, 6, 2, 10, 9, 8, 15, 16, 17, 20, 19, 12Correct answer is option 'B'. Can you explain this answer? theory, EduRev gives you an ample number of questions to practice 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 post-order traversal of this tree is:a)2, 6, 7, 8, 9, 10, 12, 15, 16, 17, 19, 20b)2, 7, 6, 10, 9, 8, 15, 17, 20, 19, 16, 12c)7, 2, 6, 8, 9, 10, 20, 17, 19, 15, 16, 12d)7, 6, 2, 10, 9, 8, 15, 16, 17, 20, 19, 12Correct answer is option 'B'. 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