Binary trees have been used to model relationships for literally thousands of years. One reason for this is that binary trees naturally model (pedigree) family trees. These are the family trees in which the root is a person, the left and right children are the person's parents, and so on, recursively. In more recent centuries binary trees have also been used to model species-trees in biology, where the leaves of the tree represent extant species and the internal nodes of the tree represent speciation events in which two populations of a single species evolve into two separate species.
Binary search trees appear to have been discovered independently by several groups in the 1950s [41, Section 6.2.2]. Further references to specific kinds of binary search trees are provided in subsequent chapters.
Write non-recursive functions , , and that return the node that follows in a pre-order, in-order, or post-order traversal, respectively.
These values should be maintained, even during the and operations, but this should not increase the cost of these operations by more than a constant factor.