Inserting 1, 2, 3, 4, 5 in order into an empty BST gives height:
Binary Search Trees
BST definition, search and insert (Java), tree shape and its effect on cost, lazy deletion, deleting the minimum, and Hibbard deletion.
How to read this page
Every original slide is shown unchanged. Yellow marks on a slide point to a numbered note: hover or tap a mark to jump to its note, and hover a note to see its marks. Questions tagged Past exam appeared on a real paper; Prediction questions are likely angles, not confirmed. Pick an answer to each question: a wrong pick tells you why it is wrong, so you can try again.
All 31 slides
- 1 A l g o r i t h m s
- 2 Slide 2
- 3 must
- 4 Binary search tree demo
- 5 Binary search tree demo
- 6 BST representation in Java
- 7 BST implementation (skeleton)
- 8 BST search: Java implementation
- 9 iii
- 10 BST insert
- 11 Slide 11
- 12 BST insert: Java implementation
- 13 Tree shape
- 14 BST insertion: random order visualization
- 15 BSTs: mathematical analysis
- 16 ST implementations: summary
- 17 Slide 17
- 18 ST implementations: summary
- 19 BST deletion: lazy approach
- 20 hasnochild
- 21 Deleting the minimum
- 22 Hibbard deletion
- 23 iw.a
- 24 soswei.es
- 25 Simlevernoses
- 26 Hibbard deletion
- 27 Hibbard deletion
- 28 Hibbard deletion: Java implementation
- 29 Hibbard deletion: analysis
- 30 commissiics
- 31 Slide 31
Tree shape
Notes
Shape depends on insertion order: random → ~1.39 lg N; sorted order → a path (N).
Exam angle
Hibbard deletion
Notes
Hibbard deletion: 0 children → remove; 1 child → replace with child; 2 children → replace with successor (min of right subtree).
Exam angle
How do you delete a node with two children from a BST?
Compare with the model answer
Find its successor (the minimum of its right subtree), copy the successor’s key into the node, then delete the successor (which has at most one child).
Hibbard deletion: analysis
Notes
Hibbard deletion makes trees unbalanced over time (√N height).