Trie Data Structure

From GM-RKB
(Redirected from prefix tree)
Jump to navigation Jump to search

A Trie Data Structure is a tree-based data structure that stores an associative array (of strings) to facilitate fast prefix-based retrieval operationss, character-by-character insertion operations, and key-specific deletion operations.



References

2024

  • (Wikipedia, 2024) ⇒ https://en.wikipedia.org/wiki/Trie Retrieved:2024-3-6.
    • In computer science, a trie , also called digital tree or prefix tree, is a type of k-ary search tree, a tree data structure used for locating specific keys from within a set. These keys are most often strings, with links between nodes defined not by the entire key, but by individual characters. In order to access a key (to recover its value, change it, or remove it), the trie is traversed depth-first, following the links between nodes, which represent each character in the key.

      Unlike a binary search tree, nodes in the trie do not store their associated key. Instead, a node's position in the trie defines the key with which it is associated. This distributes the value of each key across the data structure, and means that not every node necessarily has an associated value.

      All the children of a node have a common prefix of the string associated with that parent node, and the root is associated with the empty string. This task of storing data accessible by its prefix can be accomplished in a memory-optimized way by employing a radix tree.

      Though tries can be keyed by character strings, they need not be. The same algorithms can be adapted for ordered lists of any underlying type, e.g. permutations of digits or shapes. In particular, a bitwise trie is keyed on the individual bits making up a piece of fixed-length binary data, such as an integer or memory address. The key lookup complexity of a trie remains proportional to the key size. Specialized trie implementations such as compressed tries are used to deal with the enormous space requirement of a trie in naive implementations.

2016

2012

  • http://en.wikipedia.org/wiki/Trie#Dictionary_representation
    • A common application of a trie is storing a dictionary, such as one found on a mobile telephone. Such applications take advantage of a trie's ability to search for, insert, and delete entries quickly; however, if storing dictionary words is all that is required (i.e. storage of information auxiliary to each word is not required), a minimal acyclic deterministic finite automaton would use less space than a trie. This is because an acyclic deterministic finite automaton can compress identical branches from the trie which correspond to the same suffixes (or parts) of different words being stored.

      Tries are also well suited for implementing approximate matching algorithms, including those used in spell checking and hyphenation software.