GO-Ve01
ServicesDevelopersBooksDictionaryPapersWikidataEncyclopediaSearchBabelCareersDeck

Radix tree

In computer science, a radix tree (also radix trie or compact prefix tree or compressed trie) is a data structure that represents a space-optimized trie (prefix tree) in which each node that is the only child is merged with its parent. The number of children of every internal node is at most the radix of the radix tree, where = 2 for some integer ≥ 1. Unlike regular trees, edges can be labeled with sequences of elements as well as single elements. This makes radix trees much more efficient for small sets (especially if the strings are long) and for sets of strings that share long prefixes. Unlike regular trees (where whole keys are compared en masse from their beginning up to the point of... Source: e01 Encyclopedia. Licence: CC BY-SA 4.0.

]] In computer science, a radix tree (also radix trie or compact prefix tree or compressed trie) is a data structure that represents a space-optimized trie (prefix tree) in which each node that is the only child is merged with its parent. The number of children of every internal node is at most the radix of the radix tree, where = 2 for some integer ≥ 1. Unlike regular trees, edges can be labeled with sequences of elements as well as single elements. This makes radix trees much more efficient for small sets (especially if the strings are long) and for sets of strings that share long prefixes. Unlike regular trees (where whole keys are compared en masse from their beginning up to the point of inequality), the key at each node is compared chunk-of-bits by chunk-of-bits, where the quantity of bits in that chunk at that node is the radix of the radix trie. When is 2, the radix trie is binary (i.e., compare that node's 1-bit portion of the key), which minimizes sparseness at the expense of maximizing trie depth—i.e., maximizing up to conflation of nondiverging bit-strings in the key. When ≥ 4 is a power of 2, then the radix trie is an -ary trie, which lessens the depth of the radix trie at the expense of potential sparseness. As an optimization, edge labels can be stored in constant size by using two pointers to a string (for the first and last elements). Note that although the examples in this article show strings as sequences of characters, the type of the string elements can be chosen arbitrarily; for example, as a bit or byte of the string representation when using multibyte character encodings or Unicode. Node traverseNode := root; int elementsFound := 0; // Traverse until a leaf is found or it is not possible to continue while (traverseNode != null && !traverseNode.isLeaf() && elementsFound File:Inserting the string 'water' into a Patricia trie.png|Insert 'water' at the root File:Insert 'slower' with a null node into a Patricia trie.png|Insert 'slower' while keeping 'slow' File:Insert 'test' into a Patricia trie when 'tester' exists.png|Insert 'test' which is a prefix of 'tester' File:Inserting the word 'team' into a Patricia trie with a split.png|Insert 'team' while splitting 'test' and creating a new edge label 'st' File:Insert 'toast' into a Patricia trie with a split and a move.png|Insert 'toast' while splitting 'te' and moving previous strings a level lower == History == The data structure was invented in 1968 by Donald R. Morrison, with whom it is primarily associated, and by Gernot Gwehenberger. Donald Knuth, pages 498–500 in Volume III of The Art of Computer Programming, calls these "Patricia's trees", presumably after the acronym in the title of Morrison's paper: "PATRICIA - Practical Algorithm to Retrieve Information Coded in Alphanumeric". Today, Patricia trees are seen as radix trees with radix equals 2, which means that each bit of the key is compared individually and each node is a two-way (i.e., left versus right) branch. ==Variants== A common extension of radix trees uses two colors of nodes, "black" and "white". To check if a given string is stored in the tree, the search starts from the top and follows the edges of the input string until no further progress can be made. If the search string is consumed and the final node is a black node, the search has failed; if it is white, the search has succeeded. This makes possible to add a large range of strings with a common prefix to the tree, using white nodes, then remove a small set of "exceptions" in a space-efficient manner by inserting them using black nodes. The HAT-trie is a cache-conscious data structure based on radix trees that offers efficient string storage and retrieval, and ordered iterations. Performance, with respect to both time and space, is comparable to the cache-conscious hashtable. A PATRICIA trie is a special variant of the radix 2 (binary) trie, in which rather than explicitly store every bit of every key, the nodes store only the position of the first bit which differentiates two sub-trees. During traversal the algorithm examines the indexed bit of the search key and chooses the left or right sub-tree as appropriate. Notable features of the PATRICIA trie include that the trie only requires one node to be inserted for every unique key stored, making PATRICIA much more compact than a standard binary trie. Also, since the actual keys are no longer explicitly stored it is necessary to perform one full key comparison on the indexed record in order to confirm a match. In this respect PATRICIA bears a certain resemblance to indexing using a hash table. The adaptive radix tree is a radix tree variant that integrates adaptive node sizes to the radix tree. One major drawback of the usual radix trees is the use of space, because it uses a constant node size in every level. The major difference between the radix tree and the adaptive radix tree is its variable size for each node based on the number of child elements, which grows while adding new entries. Hence, the adaptive radix tree leads to a better use of space without reducing its speed. A common practice is to relax the criteria of disallowing parents with only one child in situations where the parent represents a valid key in the data set. This variant of radix tree achieves a higher space efficiency than the one which only allows internal nodes with at least two children. ==References== ==External links== Algorithms and Data Structures Research & Reference Material: PATRICIA, by Lloyd Allison, Monash University Patricia Tree, NIST Dictionary of Algorithms and Data Structures Crit-bit trees, by Daniel J. Bernstein Radix Tree API in the Linux Kernel, by Jonathan Corbet Kart (key alteration radix tree), by Paul Jarc The Adaptive Radix Tree: ARTful Indexing for Main-Memory Databases, by Viktor Leis, Alfons Kemper, Thomas Neumann, Technical University of Munich ===Implementations=== FreeBSD Implementation, used for paging, forwarding and other things. Linux Kernel Implementation, used for the page cache, among other things. GNU C++ Standard library has a trie implementation Java implementation of Concurrent Radix Tree, by Niall Gallagher C# implementation of a Radix Tree Practical Algorithm Template Library, a C++ library on PATRICIA tries (VC++ >=2003, GCC G++ 3.x), by Roman S. Klyujkov Patricia Trie C++ template class implementation, by Radu Gruian Haskell standard library implementation "based on big-endian patricia trees". Web-browsable source code. Patricia Trie implementation in Java, by Roger Kapsi and Sam Berlin Crit-bit trees forked from C code by Daniel J. Bernstein Patricia Trie implementation in C, in libcprops Patricia Trees : efficient sets and maps over integers (module ptmap) in OCaml, by Jean-Christophe Filliâtre Radix DB (Patricia trie) implementation in C, by G. B. Versiani Libart - Adaptive Radix Trees implemented in C, by Armon Dadgar with other contributors (Open Source, BSD 3-clause license) Nim implementation of a crit-bit tree rax, a radix tree implementation in ANSI C by Salvatore Sanfilippo (the creator of REDIS)

source: e01 Encyclopedia · licence: CC BY-SA 4.0 · page · source revision

Cite this

"Radix tree". 1786479226. e01 Encyclopedia. CC BY-SA 4.0. https://en.wikipedia.org/w/index.php?oldid=1368925962

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

Save to pass ·