PythiloLesson 16 of 32 · progress kept in this browser

Delete from a binary search tree

Deleting a leaf or a node with one child is easy: replace it with that child. A node with two children needs a stand-in that keeps the ordering, and the smallest value in its right subtree fits exactly.

# delete 3 from: 3 has children 1 and 6
# successor: smallest in right subtree -> 6
Your task

TreeNode(value) is provided. Write delete(root, value) returning the root after removing value. Leave the tree unchanged if value is absent.