BST Delete
A leaf just goes, one child is spliced past, two children need a successor.
Decision · step 2 of 8Binary Search Tree: Delete a node with two children (30)
30 is smaller than 50: go left.
What you will see
The three cases play out differently; for two children the successor travels up into the hole.
Cost
| Best | O(1) |
|---|---|
| Average | O(log n) |
| Worst | O(n) |
| Space | O(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
Taught by the same lesson
Binary Search Tree covers these too, in the same run.