Practice Discrete Math

Algorithms / Bst Invariants

Least You Need to Know: BST Invariants, Search Ranges, and Inorder Structure

Binary-search-tree reasoning is about **global range constraints**, not just comparing a node to its direct children. Inorder traversal is sorted precisely because every left subtree stays below the node and every right subtree stays above it.

The least you need to know

Key notation

low < key < high valid range constraint while descending
inorder left, node, right traversal order
BST binary search tree with ordered keys

Tiny worked example

  • Root `8` allows values `< 8` on the left and `> 8` on the right.
  • If the right child of `8` is `12`, then a descendant value `6` under that right subtree is invalid even if it is `< 12`.
  • That is why BST validation carries an interval, not just the parent value.
  • Inorder traversal of `3, 5, 7, 8, 10, 12` is sorted because the invariant holds globally.

Common mistakes

How to recognize this kind of problem

Next recommended lesson

Continue through this topic with Least You Need to Know: Condensation DAGs and Component-Level Ordering.

Least You Need to Know: Condensation DAGs and Component-Level Ordering

Related lessons

Keep going with nearby lessons in the same topic.

More ways to explore

Start practice