LESSON 3.03 · 6 STAGES · 3 CONTROLS · 3 CHECKSPRO · PREVIEW
Trees and binary search trees
Watch seven keys build a tree, and see why its height sets search cost.
Pro lesson. Stage 1 is free to watch. Pro opens all 6 stages, 3 controls and 3 checks, in this lesson and every other.
Go Pro · $8.25/moEXPLAINER · 3.03 · TREE BAY7 KEYS · 17 COMPARISONS TO BUILD
01
Stage 1 of 6 · Insert keys
Each new node starts at the root. It goes left if smaller and right if larger, to an empty link.
Explain it simply
The keys arrive one at a time, in the order shown at the top left. The first key, 89, becomes the root, the top of the tree. Each later key compares itself with a node and turns left or right, like a hiker at a fork. It stops at the first empty link.
Seven keys go in, in the order 89, 12, 31, 58, 47, 25, 64. The root is 89. The tree has height 4.
node and keylinkempty linksearch path, resultcost, deleted node
Toy: 7 keys · 1 missing key · 3 insert orders · x position = sorted rank
MATH · STAGE 1HOVER A SYMBOL OR A SHAPE
A smaller key goes left; a larger key goes right.
PRO LESSON · YOU WATCHED STAGE 1 OF 6
Unlock the full explainer
- 5 more stages and 3 live controls
- 2 mix-up cards and 3 predict-then-reveal checks
- Watch it as a narrated video, in three voices
- Every Pro lesson and capstone · 656 in total
$99 a year, or $15 a month. Cancel any time.