e01.org

trie

In computer science, a trie ( , ), also known as a digital tree or prefix tree, 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...

In computer science, a trie ( , ), also known as a digital tree or prefix tree, 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 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. ==History, etymology, and pronunciation== The idea of a trie for representing a set of strings was first abstractly described by Axel Thue in 1912. Tries were first described in a computer context by René de la Briandais in 1959. The idea was independently described in 1960 by Edward Fredkin, who coined the term trie, pronouncing it (as "tree"), after the middle syllable of retrieval. However, other authors pronounce it (as "try"), in an attempt to distinguish it verbally from "tree". ==Implementation strategies== : vertical arrows are pointers, dotted horizontal arrows are pointers. The set of strings stored in this trie is . The lists are sorted to allow traversal in lexicographic order. Tries can be represented in several ways, corresponding to different trade-offs between memory use and speed of the operations. Using a vector of pointers for representing a trie consumes enormous space; however, memory space can be reduced at the expense of running time if a singly linked list is used for each node vector, as most entries of the vector contains \text{nil} . Techniques such as alphabet reduction may reduce the large space requirements by reinterpreting the original string as a longer string over a smaller alphabet. For example, a string of bytes can alternatively be regarded as a string of four-bit units. This can reduce memory usage by a factor of eight; but lookups need to visit twice as many nodes in the worst case. Another technique includes storing a vector of 256 ASCII pointers as a bitmap of 256 bits representing ASCII alphabet, which reduces the size of individual nodes dramatically.

References

  1. ^ Connelly, Richard H.; Morris, F. Lockwood (1993). "A generalization of the trie data structure" . Mathematical Structures in Computer Science . 5 (3). Syracuse University : 381– 418. doi : 10.1017/S0960129500000803 . S2CID 18747244 . Wikipedia revision 1357162034, retrieved 2026-11-18 · 1794956400.0
  2. ^ Daciuk, Jan (24 June 2003). Comparison of Construction Algorithms for Minimal, Acyclic, Deterministic, Finite-State Automata from Sets of Strings . International Conference on Implementation and Application of Automata. Springer Publishing . pp. 255– 261. doi : 10.1007/3-540-44977-9_26 . ISBN 978-3-540-40391-3 . Wikipedia revision 1357162034, retrieved 2026-11-18 · 1794956400.0
  3. ^ Bellekens, Xavier (2014). "A Highly-Efficient Memory-Compression Scheme for GPU-Accelerated Intrusion Detection Systems". Proceedings of the 7th International Conference on Security of Information and Networks - SIN '14 . Glasgow, Scotland, UK: ACM. pp. 302:302–302:309. arXiv : 1704.02272 . doi : 10.1145/2659651.2659723 . ISBN 978-1-4503-3033-6 . S2CID 12943246 . Wikipedia revision 1357162034, retrieved 2026-11-18 · 1794956400.0
  4. ^ Sartaj Sahni (2004). "Data Structures, Algorithms, & Applications in C++: Tries" . University of Florida . Archived from the original on 3 July 2016 . Retrieved 17 April 2022 . Wikipedia revision 1357162034, retrieved 2026-11-18 · 1794956400.0
  5. ^ Mehta, Dinesh P.; Sahni, Sartaj (7 March 2018). "Tries". Handbook of Data Structures and Applications (2 ed.). Chapman & Hall , University of Florida . ISBN 978-1498701853 . Wikipedia revision 1357162034, retrieved 2026-11-18 · 1794956400.0
  6. ^ Jan Daciuk; Stoyan Mihov; Bruce W. Watson; Richard E. Watson (1 March 2000). "Incremental Construction of Minimal Acyclic Finite-State Automata" . Computational Linguistics . 26 (1). MIT Press : 3– 16. arXiv : cs/0007009 . Bibcode : 2000cs........7009D . doi : 10.1162/089120100561601 . Wikipedia revision 1357162034, retrieved 2026-11-18 · 1794956400.0
  7. ^ "Patricia tree" . National Institute of Standards and Technology . Archived from the original on 14 February 2022 . Retrieved 17 April 2022 . Wikipedia revision 1357162034, retrieved 2026-11-18 · 1794956400.0
  8. ^ Kärkkäinen, Juha. "Lecture 2" (PDF) . University of Helsinki . The preorder of the nodes in a trie is the same as the lexicographical order of the strings they represent assuming the children of a node are ordered by the edge labels. Wikipedia revision 1357162034, retrieved 2026-11-18 · 1794956400.0
  9. ^ Kallis, Rafael (2018). "The Adaptive Radix Tree (Report #14-708-887)" (PDF) . University of Zurich: Department of Informatics, Research Publications . Wikipedia revision 1357162034, retrieved 2026-11-18 · 1794956400.0
  10. ^ Giancarlo, Raffaele (28 May 1992). "A Generalization of the Suffix Tree to Square Matrices, with Applications" . SIAM Journal on Computing . 24 (3). Society for Industrial and Applied Mathematics : 520– 562. doi : 10.1137/S0097539792231982 . ISSN 0097-5397 . Wikipedia revision 1357162034, retrieved 2026-11-18 · 1794956400.0
  11. ^ Transier, Frederik; Sanders, Peter (December 2010). "Engineering basic algorithms of an in-memory text search engine" . ACM Transactions on Information Systems . 29 (1). Association for Computing Machinery : 1– 37. doi : 10.1145/1877766.1877768 . S2CID 932749 . Wikipedia revision 1357162034, retrieved 2026-11-18 · 1794956400.0
  12. ^ de la Briandais, René (1959). File searching using variable length keys (PDF) . Proc. Western J. Computer Conf. pp. 295– 298. doi : 10.1145/1457838.1457895 . S2CID 10963780 . Archived from the original (PDF) on 2020-02-11. Cited by Brass and by Knuth. Wikipedia revision 1357162034, retrieved 2026-11-18 · 1794956400.0
  13. ^ "Trie" . School of Arts and Science, Rutgers University . 2022. Archived from the original on 17 April 2022 . Retrieved 17 April 2022 . Wikipedia revision 1357162034, retrieved 2026-11-18 · 1794956400.0
  14. ^ a b Black, Paul E. (2009-11-16). "trie" . Dictionary of Algorithms and Data Structures . National Institute of Standards and Technology . Archived from the original on 2011-04-29. Wikipedia revision 1357162034, retrieved 2026-11-18 · 1794956400.0
  15. ^ a b c d Knuth, Donald (1997). "6.3: Digital Searching". The Art of Computer Programming Volume 3: Sorting and Searching (2nd ed.). Addison-Wesley. p. 492. ISBN 0-201-89685-0 . Wikipedia revision 1357162034, retrieved 2026-11-18 · 1794956400.0
  16. ^ a b c d e Franklin Mark Liang (1983). Word Hy-phen-a-tion By Com-put-er (PDF) (Doctor of Philosophy thesis). Stanford University. Archived (PDF) from the original on 2005-11-11 . Retrieved 2010-03-28 . Wikipedia revision 1357162034, retrieved 2026-11-18 · 1269730800.0
  17. ^ Yang, Lai; Xu, Lida; Shi, Zhongzhi (23 March 2012). "An enhanced dynamic hash TRIE algorithm for lexicon search". Enterprise Information Systems . 6 (4): 419– 432. Bibcode : 2012EntIS...6..419Y . doi : 10.1080/17517575.2012.665483 . S2CID 37884057 . Wikipedia revision 1357162034, retrieved 2026-11-18 · 1794956400.0
  18. ^ a b Aho, Alfred V.; Corasick, Margaret J. (Jun 1975). "Efficient String Matching: An Aid to Bibliographic Search" . Communications of the ACM . 18 (6): 333– 340. doi : 10.1145/360825.360855 . S2CID 207735784 . Wikipedia revision 1357162034, retrieved 2026-11-18 · 1794956400.0
  19. ^ a b c d Brass, Peter (8 September 2008). Advanced Data Structures . UK : Cambridge University Press . doi : 10.1017/CBO9780511800191 . ISBN 978-0521880374 . Wikipedia revision 1357162034, retrieved 2026-11-18 · 1794956400.0
  20. ^ Ranjan Sinha and Justin Zobel and David Ring (Feb 2006). "Cache-Efficient String Sorting Using Copying" (PDF) . ACM Journal of Experimental Algorithmics . 11 : 1– 32. doi : 10.1145/1187436.1187439 . S2CID 3184411 . Wikipedia revision 1357162034, retrieved 2026-11-18 · 1794956400.0
  21. ^ a b Maabar, Maha (17 November 2014). "Trie Data Structure" . CVR, University of Glasgow . Archived from the original on 27 January 2021 . Retrieved 17 April 2022 . Wikipedia revision 1357162034, retrieved 2026-11-18 · 1794956400.0
  22. ^ a b c d e f Gonnet, G. H.; Yates, R. Baeza (January 1991). Handbook of algorithms and data structures: in Pascal and C (2 ed.). Boston , United States : Addison-Wesley . ISBN 978-0-201-41607-7 . Wikipedia revision 1357162034, retrieved 2026-11-18 · 1794956400.0
  23. ^ a b c Crochemore, Maxime; Lecroq, Thierry (2009). "Trie". Encyclopedia of Database Systems . Boston , United States : Springer Publishing . Bibcode : 2009eds..book.....L . doi : 10.1007/978-0-387-39940-9 . ISBN 978-0-387-49616-0 – via HAL (open archive) . Wikipedia revision 1357162034, retrieved 2026-11-18 · 1794956400.0
  24. ^ a b c Martinez-Prieto, Miguel A.; Brisaboa, Nieves; Canovas, Rodrigo; Claude, Francisco; Navarro, Gonzalo (March 2016). "Practical compressed string dictionaries" . Information Systems . 56 . Elsevier : 73– 108. doi : 10.1016/j.is.2015.08.008 . hdl : 10533/147675 . ISSN 0306-4379 . Wikipedia revision 1357162034, retrieved 2026-11-18 · 1794956400.0
  25. ^ a b c d e Thareja, Reema (13 October 2018). "Hashing and Collision". Data Structures Using C (2 ed.). Oxford University Press . ISBN 9780198099307 . Wikipedia revision 1357162034, retrieved 2026-11-18 · 1794956400.0
  26. ^ a b c d e f Sedgewick, Robert ; Wayne, Kevin (3 April 2011). Algorithms (4 ed.). Addison-Wesley , Princeton University . ISBN 978-0321573513 . Wikipedia revision 1357162034, retrieved 2026-11-18 · 1794956400.0
  27. ^ J. Kärkkäinen and T. Rantala (2008). "Engineering Radix Sort for Strings". In A. Amir and A. Turpin and A. Moffat (ed.). String Processing and Information Retrieval, Proc. SPIRE . Lecture Notes in Computer Science. Vol. 5280. Springer. pp. 3– 14. doi : 10.1007/978-3-540-89097-3_3 . ISBN 978-3-540-89096-6 . Wikipedia revision 1357162034, retrieved 2026-11-18 · 1794956400.0
  28. ^ Thue, Axel (1912). "Über die gegenseitige Lage gleicher Teile gewisser Zeichenreihen" . Skrifter Udgivne Af Videnskabs-Selskabet I Christiania . 1912 (1): 1– 67. Cited by Knuth. Wikipedia revision 1357162034, retrieved 2026-11-18 · 1794956400.0
  29. ^ a b Edward Fredkin (1960). "Trie Memory" . Communications of the ACM . 3 (9): 490– 499. doi : 10.1145/367390.367400 . S2CID 15384533 . Wikipedia revision 1357162034, retrieved 2026-11-18 · 1794956400.0
  30. ^ a b Willar, Dan E. (27 January 1983). "Log-logarithmic worst-case range queries are possible in space O(n)" . Information Processing Letters . 17 (2): 81– 84. doi : 10.1016/0020-0190(83)90075-3 . Wikipedia revision 1357162034, retrieved 2026-11-18 · 1794956400.0
  31. trie. https://en.wikipedia.org/w/index.php?oldid=1357162034 · 1795438144.7002156
source: e01 Encyclopedia · licence: CC BY-SA 4.0 · page · source revision

Cite this

"trie". 1780273665. e01 Encyclopedia. CC BY-SA 4.0. https://en.wikipedia.org/w/index.php?oldid=1357162034

JSON record · API collection · BibTeX · RIS · CSL-JSON · citation policy

Save to pass ·