LOGBOOK

HELP

Quiz Entry - updated: 2026.12.01

How does the ordering of a binary search tree differ from that of a heap, and what does each make fast?

A binary search tree orders left against right (left subtree ≤ node ≤ right subtree), which makes searching for any key fast. A heap orders parent against children (parent ≤ children) and leaves left and right unordered, which only makes the minimum fast.

Binary search tree Min-heap
Ordering rule left subtree ≤ node ≤ right subtree parent ≤ children
Left vs right strictly ordered undefined
Shape any binary tree complete, filled from the left
Fast operation find any key: $O(h)$ min: $O(1)$, removeMin: $O(\log n)$
Find an arbitrary key $O(h)$ $O(n)$
Inorder traversal sorted not sorted
Height guarantee none (up to n) always $O(\log n)$

The two structures make opposite bargains. The heap's weak order is cheap to maintain and its forced shape guarantees a logarithmic height, but it can only answer "what is the smallest?". The search tree's strong order answers "where is key k?" for any k, but nothing stops it from growing lopsided.

From Quiz: ADS / Binary Search Trees | Updated: Dec 01, 2026