Computing Atlas

How Computing Was Built
Sign In
Text size
100%
Theme
Algorithm

Ternary Search Tree Algorithm

Searching Algorithm

A ternary search tree is a trie-like data structure, sometimes described as a type of prefix tree, whose nodes are arranged similarly to a binary search tree but with up to three children rather than two. Each node stores a single character together with three child pointers, a low child for characters that sort before it, a high child for characters that sort after it, and an equal child that leads to the next character of the same string, so that walking down a path of equal children spells out a stored string one character at a time. This layout makes ternary search trees more space efficient than a standard prefix trie at some cost in lookup speed, and they are well suited to storing large numbers of relatively short strings that share common prefixes, with common applications including spell checking, autocompletion, near-neighbor string search and database indexing.

Sources
NIST Dictionary of Algorithms and Data Structures: ternary search tree
NIST Dictionary of Algorithms and Data StructuresIn Group: Search Trees and Dictionary Structures, Definition
Quote, In Group: Search Trees and Dictionary Structures, Definition
A 3-way tree where every node's left subtree has keys less than the node's key, every middle subtree has keys equal to the node's key, and every right subtree has keys greater than the node's key.
View the Source
Comments (0)
No comments yet. Be the first to share a thought.
Reader Challenges (0)
No disputes yet. Spotted an error or a better source? Open the first one.