We're sorry but this app doesn't work properly without JavaScript enabled. Please enable it to continue.

This lesson's interactive features are locked, please to keep using them

Deletion Review

The delete method is O(log(n)) because, like most binary tree operations, we don't have to search the entire tree. We only have to search one path from the root to the leaf node we want to delete.

The depth of the tree on average is equal to log base 2 of the number of nodes in the tree. For example:

NodesDepth
10
21
42
83
164
325
646
1287
2568
5129
102410
204811
409612

We only need to use ~10 steps to delete a node from a tree of ~1000 nodes.