In a binary search tree (BST), which traversal order visits the keys in strictly ascending sorted order?

Answer and explanation

Correct answer: C. In-order traversal

  1. Step 1: A BST satisfies: left subtree root right subtree for every node.
  2. Step 2: In-order traversal visits: (1) Left subtree, (2) Root node, (3) Right subtree.
  3. Step 3: Because left values are smaller and right values are larger, in-order output is monotonically increasing.
Answer
In-order traversal.
Why not the others: 'Pre-order' visits root first (used for cloning trees); 'Post-order' visits root last (used for deleting trees); 'Level-order' is breadth-first search.

Practise more Python Programming, Data Structures, Algorithms, Networks and Cybersecurity.

Free questions with an explanation for every one, and full timed Saudi Secondary School Certificate mock tests.