In computer science, a search tree is a binary tree data structure in whose nodes data values are stored from some ordered set, in such a way that in-order traversal of the tree visits the nodes in ascending order of the stored values. This means that for any internal node containing a value v, the values x stored in its left subtree satisfy x ≤ v, and the values y stored in its right subtree satisfy v ≤ y. Each subtree of a search tree is by itself again a search tree.
Search trees can implement the data type of (finite) multisets. The advantage of using search trees is that the test for membership can be performed efficiently provided that the tree is reasonably balanced, that is, the leaves of the tree are at comparable depths. Various search-tree data structures exist, several of which also allow efficient insertion and deletion of elements, which operations then have to maintain tree balance. If the multiset being represented is immutable, this is not an issue.
Search trees can also implement associative arrays by storing key–value pairs, where the ordering is based on the key part of these pairs.
In some kinds of search trees the data values are all stored in the leaves of the tree. In that case some additional information needs to be stored in the internal tree nodes to make efficient operations possible.
Read more about Search Tree: Examples
Famous quotes containing the words search and/or tree:
“His life itself passes deeper in nature than the studies of the naturalist penetrate; himself a subject for the naturalist. The latter raises the moss and bark gently with his knife in search of insects; the former lays open logs to their core with his axe, and moss and bark fly far and wide. He gets his living by barking trees. Such a man has some right to fish, and I love to see nature carried out in him.”
—Henry David Thoreau (18171862)
“Behold I have given you every herb bearing seed which is upon the face of all the earth, and every tree, in which is the fruit of a tree yielding seed; to you it shall be for meat.”
—Bible: Hebrew Genesis 1:29.
But in a later context, God told the disgraced Adam, and thou shalt eat the herb of the field (Genesis 3:18)