LOGBOOK

HELP

Quiz Entry - updated: 2026.11.26

How is a node whose two children are both external removed? Give the example remove(4) in the tree 6 → (2, 9), 2 → (1, 4), 9 → (8).

Let w be one of v's external children and call removeExternal(w): this deletes w and v, and w's sibling w″, also external, takes v's place. Removing 4 simply turns the right child of 2 into an external node.

Step by step for remove(4):

  1. TreeSearch(4) finds v = 4 via 6 → 2 → 4.
  2. Both children of 4 are external. Pick one, w.
  3. removeExternal(w) removes w and 4; the other external node w″ moves into 4's place as the right child of 2.

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

This is the easiest case: a node without internal children is a leaf of the data, and nothing below it has to be relocated.

remove(4) where 4 has two external children: 4 and one external node disappear, the other external node takes 4's place

* removeExternal(w) deletes w and v; the sibling w″ moves up into v's place. *

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