Our website is made possible by displaying online advertisements to our visitors.
Please consider supporting us by disabling your ad blocker.

Responsive image


Trie

Trie
TypeTree
Invented1960
Invented byEdward Fredkin, Axel Thue, and René de la Briandais
Time complexity in big O notation
Operation Average Worst case
Search O(n) O(n)
Insert O(n) O(n)
Delete O(n) O(n)
Space complexity
Space O(n) O(n)
Depiction of a trie. Single empty circle, representing the root node, points to three children. The arrow to each child is marked by a different letter. The children themselves have similar set of arrows and child nodes, with nodes that correspond to full words bearing blue integer values.
A trie for keys "A", "to", "tea", "ted", "ten", "i", "in", and "inn". Each complete English word has an arbitrary integer value associated with it.

In computer science, a trie (/ˈtr/, /ˈtr/), also known as a digital tree or prefix tree,[1] is a specialized search tree data structure used to store and retrieve strings from a dictionary or set. Unlike a binary search tree, nodes in a trie do not store their associated key. Instead, each node's position within the trie determines its associated key, with the connections between nodes defined by individual characters rather than the entire key.

Tries are particularly effective for tasks such as autocomplete, spell checking, and IP routing, offering advantages over hash tables due to their prefix-based organization and lack of hash collisions. Every child node shares a common prefix with its parent node, and the root node represents the empty string. While basic trie implementations can be memory-intensive, various optimization techniques such as compression and bitwise representations have been developed to improve their efficiency. A notable optimization is the radix tree, which provides more efficient prefix-based storage.

While tries commonly store character strings, they can be adapted to work with any ordered sequence of elements, such as permutations of digits or shapes. A notable variant is the bitwise trie, which uses individual bits from fixed-length binary data (such as integers or memory addresses) as keys.

  1. ^ Maabar, Maha (17 November 2014). "Trie Data Structure". CVR, University of Glasgow. Archived from the original on 27 January 2021. Retrieved 17 April 2022.

Previous Page Next Page






الشجرة الرقمية Arabic Прэфікснае дрэва BE Trie Catalan Trie Czech Trie German Trie Spanish Prefiksipuu ET درخت پیشوندی FA Trie (informatique) French Trie GL

Responsive image

Responsive image