Computer Science I / Trees and Hierarchical Storage
Practice question · Multiple choice

Searching a balanced binary search tree of 1023 nodes takes at most 10 comparisons; scanning a list of the same values takes up to 1023. Why does the tree save so much, and what does the saving depend on?

Hints
  1. At the root you compare once. How many nodes have you eliminated from consideration?
  2. 1023 nodes, 10 comparisons. What is 2 to the power of 10?
Show the answer

B. From discarding half the remaining candidates at every comparison.

Why

One comparison at the root discards half the tree entirely — not examined and rejected, never visited — so the candidate set halves each step: 1023, 511, 255, down to 1 in ten. Cost tracks height, and a balanced tree's height is about log₂ n. Sorted order alone is not the mechanism: a sorted list scanned linearly still takes n steps, and the halving is what saves the work.

Read the lesson: Trees and Hierarchical Storage →

Practise Trees and Hierarchical Storage

The app has 5 more questions on this lesson, and keeps your place in the course. Computer Science I is free to start.

More questions on Trees and Hierarchical Storage