logo

Question detail

The values in the following binary search tree are arranged so that an in-order traversal should produce them in ascending order. Which sequence is produced by an in-order traversal of this tree: root 50, left child 30, right child 70, 30's children 20 and 40, and 70's children 60 and 80?

Try the question, check the answer, then read the explanation to understand the curriculum point.

At a glance

MCQ

Type

practice

Style

Topic

Tree-traversal

Exam-style question

Try this first

The values in the following binary search tree are arranged so that an in-order traversal should produce them in ascending order. Which sequence is produced by an in-order traversal of this tree: root 50, left child 30, right child 70, 30's children 20 and 40, and 70's children 60 and 80?.

  1. A.50, 30, 20, 40, 70, 60, 80
  2. B.20, 30, 40, 50, 60, 70, 80
  3. C.20, 40, 30, 60, 80, 70, 50
  4. D.80, 70, 60, 50, 40, 30, 20

Model answer

What a good answer should say

  • 20, 30, 40, 50, 60, 70, 80

Explanation

Why this works

In-order visits the left subtree, then the current node, then the right subtree. For a binary search tree, this outputs the contents in ascending order.

Common mistake

No common mistake is linked to this question yet.

Related flashcards

No flashcards are published for this page yet.

Related practice questions

No questions are published for this page yet.