LOGBOOK

HELP

Quiz Entry - updated: 2026.11.26

How is a node with exactly one external child removed? Give the example remove(4) where 4's left child is external and its right child is 5.

Call removeExternal(w) on the external child w: it deletes w and v, and v's other child, the internal subtree, moves up into v's place. Here 5 becomes the right child of 2.

Tree before: 6 → (2, 9), 2 → (1, 4), 4 → (external, 5), 9 → (8).

  1. TreeSearch(4) finds v = 4.
  2. 4's left child w is external, the right child is 5.
  3. removeExternal(w) deletes w and 4; the sibling, 5 with its whole subtree, takes 4's place.

Result: 6 → (2, 9), 2 → (1, 5), 9 → (8). Inorder: 1, 2, 5, 6, 8, 9.

The ordering property holds automatically. Everything in 4's right subtree was > 2 and < 6 (it sat in 2's right subtree and 6's left subtree), and it is still in exactly those subtrees after moving up. The subtree moves as a whole; nothing inside it is touched.

remove(4) with one external child: the external child and 4 disappear, 5 moves up into 4's position

* The remaining child's subtree moves up one level, unchanged. *

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