## Two cases:

- x has a right subtree: successor is minimum node in right subtree
- x has no right subtree: successor is first ancestor of x whose left child is also ancestor of x
- Intuition: As long as you move to the left up the tree, you’re visiting smaller nodes.

## Predecessor: similar algorithm

Previous slide | Next slide | Back to first slide | View graphic version |