AlgoScope

BST Insert

AlgorithmbeginnerBST Operations

Search for the value and hang a new leaf wherever the search runs out of tree.

Decision · step 2 of 6Binary Search Tree: Insert 65
20304050✓607080current50 > 65

65 is larger than 50: go right.

Open in the player →or start at step 2

What you will see

COMPARE -> MOVE -> the empty spot is highlighted -> the node grows in with its edge.

How binary search tree works →

Cost

BestO(1)
AverageO(log n)
WorstO(n)
SpaceO(1)

How you work with it here

play it through, step one change at a time, scrub to any step, run it on your own input, predict what happens next, try operations in any order.

Screen readers: Nodes announce value, left child and right child; each step announces the comparison and the direction taken or the structural change.

Reduced motion: Focus jumps node to node with a static ring; rotations become a crossfade between the two layouts.

Before this

Related

Leads to

Topics that need this one first.

Taught by the same lesson

Binary Search Tree covers these too, in the same run.