encyclopegia.org

search tree

In computer science, a search tree is a tree data structure used for locating specific keys from within a set.[src] In order for a tree to function as a search tree, the key for each node must be greater than any keys in subtrees on the left, and less than any keys in subtrees on the right.[src] The advantage of search trees is their efficient search time given the tree is reasonably balanced, which is to say the leaves at either end are of comparable depths.[src] 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.[src] Search trees are often used to implement an associative array.[src] The search tree algorithm uses the key from the key–value pair to find a location, and then the application stores the entire key–value pair at that particular location.[src]

In computer science, a search tree is a tree data structure used for locating specific keys from within a set.[src] In order for a tree to function as a search tree, the key for each node must be greater than any keys in subtrees on the left, and less than any keys in subtrees on the right.[src] The advantage of search trees is their efficient search time given the tree is reasonably balanced, which is to say the leaves at either end are of comparable depths.[src] 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.[src] Search trees are often used to implement an associative array.[src] The search tree algorithm uses the key from the key–value pair to find a location, and then the application stores the entire key–value pair at that particular location.[src] ==Types of trees== ===Binary search tree=== A Binary Search Tree is a node-based data structure where each node contains a key and two subtrees, the left and right.[src] For all nodes, the left subtree's key must be less than the node's key, and the right subtree's key must be greater than the node's key.[src] These subtrees must all qualify as binary search trees.[src] The worst-case time complexity for searching a binary search tree is the height of the tree, which can be as small as O(log n) for a tree with n elements.[src] ===B-tree=== B-trees are generalizations of binary search trees in that they can have a variable number of subtrees at each node.[src] While child-nodes have a pre-defined range, they will not necessarily be filled with data, meaning B-trees can potentially waste some space.[src] The advantage is that B-trees do not need to be re-balanced as frequently as other self-balancing trees.[src] Due to the variable range of their node length, B-trees are optimized for systems that read large blocks of data, they are also commonly used in databases.[src] The time complexity for searching a B-tree is O(log n).[src] ===(a,b)-tree=== An (a,b)-tree is a search tree where all of its leaves are the same depth.[src] Each node has at least a children and at most b children, while the root has at least 2 children and at most b children.[src] a and b can be decided with the following formula: 2 \le a \le \frac{(b+1)}{2} The time complexity for searching an (a,b)-tree is O(log n).[src] ===Ternary search tree=== A ternary search tree is a type of tree that can have 3 nodes: a low child, an equal child, and a high child.[src] Each node stores a single character and the tree itself is ordered the same way a binary search tree is, with the exception of a possible third node.[src] Searching a ternary search tree involves passing in a string to test whether any path contains it.[src] The time complexity for searching a balanced ternary search tree is O(log n).[src] ==Searching algorithms== ===Searching for a specific key=== Assuming the tree is ordered, we can take a key and attempt to locate it within the tree.[src] The following algorithms are generalized for binary search trees, but the same idea can be applied to trees of other formats.[src] ====Recursive==== search-recursive(key, node) if node is NULL return EMPTY_TREE if key node.key return search-recursive(key, node.right) else return node ====Iterative==== searchIterative(key, node) currentNode := node while currentNode is not NULL if currentNode.key = key return currentNode else if currentNode.key > key currentNode := currentNode.left else currentNode := currentNode.right ===Searching for min and max=== In a sorted tree, the minimum is located at the node farthest left, while the maximum is located at the node farthest right.[src] ====Minimum==== findMinimum(node) if node is NULL return EMPTY_TREE min := node while min.left is not NULL min := min.left return min.key ====Maximum==== findMaximum(node) if node is NULL return EMPTY_TREE max := node while max.right is not NULL max := max.right return max.key ==See also== Trie Binary tree Depth-first search ==References==[src]

32 sentences · 32 cited inline · 0 references stored

References

No reference rows published for this article.

Cite this article

MLA

"search tree." encyclopegia.org, 2025, https://encyclopegia.org/wiki/search-tree. Accessed 30 November 2026.

Chicago

"search tree." encyclopegia.org. Accessed November 30, 2026. https://encyclopegia.org/wiki/search-tree.

APA

encyclopegia.org. (2025). search tree. Retrieved November 30, 2026, from https://encyclopegia.org/wiki/search-tree

Accessed November 30, 2026 · CC BY-SA 4.0 · citation page · JSON

Related articles

Google Search

stub · references available

Ti -Tree

stub · references available

search and rescue dog

stub · references available

Siberian Tree Frog

stub · references available

Olive-tree Warbler

stub · references available

Tree Pipit

stub · references available

Matschie's tree-kangaroo

stub · references available

phylogenetic tree

stub · references available
CC BY-SA 4.0 · tier1-factual · https://en.wikipedia.org/w/index.php?oldid=1325229642 · 0.55 · snapshot search-tree-071424-fe20b5ec1928b8c9 · QID Q621673

Cite · JSON · Search

Related services and records

Services

  • Estate — measured countries, lanes and facts
  • Intel — live corroborated events
  • Legal — statutes, cases and citations
  • Encyclopedia — articles with inline sources
  • Space — launches, satellites and orbits
  • Search — federated search and reports
  • Pass — passport account and SSO
  • Corpora — read-only corpus origins
  • e01 — self-hosted corpora and tools
  • Careers — open roles: frontier engineers and sales partners
  • Index — every corpus, paper and record
  • Estate guide — what a public data estate is
  • Founder — Lois-Kleinner Alpasan
  • Records — DOIs and external deposits
  • Documents — one-pagers, PDFs and QR codes
  • Brand kit — logos and share images
  • Papers — plain-language briefs with citations
  • Browser — search engine, PWA and bookmarklet
  • Anticloud — the operator and its projects

As seen in Business Insider · 336 outlets · evidence DOIs · plain-language papers

Text and metadata only; each target carries its own sources. Missing data is published as no-data, never estimated.