LOGBOOK

HELP

Quiz Entry - updated: 2026.11.26

In the map tree 5 → (3, 6), 3 → (1, 4), 1 → (external, 2), what does the tree look like after delete(1) and then delete(5)?

After delete(1): 5 → (3, 6), 3 → (2, 4). After delete(5): 4 → (3, 6), 3 → (2).

delete(1): node 1 has an external left child and the internal right child 2: case 2. removeExternal on the left external child deletes 1, and 2 moves up into its place as the left child of 3.

delete(5): the root has two internal children (3 and 6): case 3.

  1. The inorder predecessor of 5: left to 3, then right as far as possible, to 4. 4's right child is external, so w = 4.
  2. Copy (4, Vier:2) into the root.
  3. Delete the old node 4: both of its children are external, case 1. 3's right child becomes external.

The final tree has root 4, children 3 and 6, and 2 as 3's left child. Inorder: 2, 3, 4, 6, matching the remaining keys in sorted order.

The tree after the inserts, after delete(1) and after delete(5), with the moved key highlighted

* delete(1) is case 2; delete(5) copies the predecessor 4 into the root. *

From Quiz: ADS / Binary Search Trees | Updated: Nov 26, 2026