logo

AQA A-Level Computer Science practice

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 first, then check the answer and practise the same topic again.

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

Answer and explanation

Concise answer

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

Why this is correct

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.

Use the concise answer above for a quick check, then reveal the full model answer and detailed explanation.

Common mistake

No common mistake is linked to this question yet.

Related flashcards

No flashcards are published for this page yet.

Related practice questions