Binary search tree

Find a number in the tree. At each fork, compare it with just one key.

Every key in the left subtree is smaller, and every key in the right subtree is larger. Equality ends the search.

Deleting a leaf, a node with one child and a node with two children changes different links.

Search, insertion and deletion take O(h) time, where h is the height. A chain of n nodes has height n.