Download Radix tree - Wikipedia, the free encyclopedia

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts

B-tree wikipedia , lookup

Quadtree wikipedia , lookup

Lattice model (finance) wikipedia , lookup

Red–black tree wikipedia , lookup

Interval tree wikipedia , lookup

Binary search tree wikipedia , lookup

Transcript
Lo g in / create acco unt
Article Discussion
Read Edit
Search
Radix tree
Fro m Wikipedia, the free encyclo pedia
Main page
Co ntents
Featured co ntent
Current events
Rando m article
Do nate to Wikipedia
Interactio n
Help
Abo ut Wikipedia
Co mmunity po rtal
Recent changes
Co ntact Wikipedia
To o lbo x
Print/expo rt
Languages
Deutsch
‫ﻓﺎرﺳﯽ‬
Français
日本語
Po lski
Po rtuguês
中文
In computer science , a radix tree is a space- optimiz ed trie data structure where
each node with only one child is merged with its child. The result is that every
internal node has at least two children. Unlike in regular tries, edges can be
labeled with sequences of characters as well as single characters. This makes
them much more efficient for small sets (especially if the strings are long) and for
sets of strings that share long prefixes.
It supports the following main operations, all of which are O( k ), where k is the
maximum length of all strings in the set:
Lookup: Determines if a string is in the set. This operation is identical to tries
except that some edges consume multiple characters.
Insert: Add a string to the tree. We search the tree until we can make no further
progress. At this point we either add a new outgoing edge labeled with all remaining characters in the input string, or if there is already
an outgoing edge sharing a prefix with the remaining input string, we split it into two edges (the first labeled with the common prefix)
and proceed. This splitting step ensures that no node has more children than there are possible string characters.
Delete: Delete a string from the tree. First, we delete the corresponding leaf. Then, if its parent only has one child remaining, we delete
the parent and merge the two incident edges.
Find predecessor: Locates the largest string less than a given string, by lexicographic order.
Find successor: Locates the smallest string greater than a given string, by lexicographic order.
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 enables us 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.
Co nt e nt s [hide]
1 Applicatio ns
PDFmyURL.com
2 Histo ry
3 Co mpariso n to o ther data structures
4 Variants
5 References
6 External links
6 .1 Implementatio ns
Applications
[edit]
As mentioned, radix trees are useful for constructing associative arrays with keys that can be expressed as strings. They find particular
application in the area of IP routing, where the ability to contain large ranges of values with a few exceptions is particularly suited to the
hierarchical organiz ation of IP addresses.[1] They are also used for inverted indexes of text documents in information retrieval.
History
[edit]
Donald R. Morrison first described what he called "Patricia trees" in 1968; [2] the name comes from the acronym PATRICIA, which stands
for "Practical Algorithm To Retrieve Information Coded In Alphanumeric ". Gernot Gwehenberger independently invented and described the
data structure at about the same time.[3]
Comparison to other data structures
[edit]
(In the following comparisons, it is assumed that the keys are of length k and the data structure contains n elements.)
Unlike balanced trees, radix trees permit lookup, insertion, and deletion in O(k ) time rather than O(log n). This doesn't seem like an
advantage, since normally k ≥ log n, but in a balanced tree every comparison is a string comparison requiring O(k ) worst- case time,
many of which are slow in practice due to long common prefixes. In a trie, all comparisons require constant time, but it takes m
comparisons to look up a string of length m. Radix trees can perform these operations with fewer comparisons and require many fewer
nodes.
Radix trees also share the disadvantages of tries, however: as they can only be applied to strings of elements or elements with an
efficiently reversible mapping (injection) to strings, they lack the full generality of balanced search trees, which apply to any data type with
a total ordering. A reversible mapping to strings can be used to produce the required total ordering for balanced search trees, but not the
other way around. This can also be problematic if a data type only provides a comparison operation, but not a (de) serializ ation
operation.
Hash tables are commonly said to have expected O(1) insertion and deletion times, but this is only true when considering computation of
the hash of the key to be a constant time operation. When hashing the key is taken into account, hash tables have expected O(k )
insertion and deletion times, but may take longer in the worst- case depending on how collisions are handled. Radix trees have worstcase O(k ) insertion and deletion. The successor/predecessor operations of radix trees are also not implemented by hash tables.
PDFmyURL.com
Variants
[edit]
The HAT- t rie is a radix tree based cache- conscious data structure 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. [4] [5]
References
[edit]
1. ^ Knizhnik, Ko nstantin. "Patricia Tries: A Better Index Fo r Prefix Searches"
, Dr. Dobb's Journal , June, 20 0 8 .
2. ^ Mo rriso n, Do nald R. Practical Algo rithm to Retrieve Info rmatio n Co ded in Alphanumeric
3. ^ G. Gwehenberger, Anwendung einer binären Verweiskettenmetho de beim Aufbau vo n Listen.
223–226
Elektro nische Rechenanlagen 10 (19 6 8 ), pp.
4. ^ Askitis, Niko las; Sinha, Ranjan (20 0 7). HAT-trie: A Cache-conscious Trie-based Data Structure for Strings
6 8 243-0
5. ^ Askitis, Niko las; Sinha, Ranjan (20 10 ). Engineering scalable, cache and space efficient tries for strings
9 . ISBN 10 6 6 -8 8 8 8 (Print) 0 9 49 -8 77X (Online).
. 6 2. pp. 9 7–10 5. ISBN 1-9 20 . do i:10 .10 0 7/s0 0 778 -0 10 -0 18 3-
External links
[edit]
Algorithms and Data Structures Research & Reference Material: PATRICIA
Patricia Tree
Crit- bit trees
, by Lloyd Allison, Monash University
, NIST Dictionary of Algorithms and Data Structures
, by Daniel J. Bernstein
Radix Tree API in the Linux Kernel
Kart (key alteration radix tree)
, by Jonathan Corbet
, by Paul Jarc
Implementations
[edit]
GNU C++ Standard library has a trie implementation
A heavily commented dictionary implementation with a binary Radix Tree
assembler)
Java implementation of Radix Tree
, by Herbert Glarner (in Linoleum, a cross platform
, by Tahseen Ur Rehman
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
Patricia Trie implementation in Java
Crit- bit trees
"based on big- endian patricia trees". Web- browsable source code
.
, by Roger Kapsi and Sam Berlin
forked from C code by Daniel J. Bernstein
Patricia Trie implementation in C , in libcprops
v·d·e
Tre e s in co m put e r scie nce
[hide]
PDFmyURL.com
B inary t re e s
Se lf - b alancing b inary se arch t re e s
B - t re e s
Binary search tree (BST) · Cartesian tree · Top Tree · T- tree
AA tree · AVL tree · Red- black tree · Scapegoat tree · Splay tree · Treap
B+ tree · B*- tree · B x- tree · UB- tree · 2- 3 tree · 2- 3- 4 tree · (a,b)- tree · Dancing tree · Htree
Trie s
Suffix tree · R ad ix t re e · Ternary search tree
B inary sp ace p art it io ning ( B SP) t re e s
Quadtree · Octree · kd- tree (implicit) · VP- tree
N o n- b inary t re e s
Sp at ial d at a p art it io ning t re e s
O t he r t re e s
Exponential tree · Fusion tree · Interval tree · PQ tree · Range tree · SPQR tree · Van Emde Boas tree
R- tree · R+ tree · R* tree · X- tree · M- tree · Segment tree · Fenwick tree · Hilbert R- tree
Heap · Hash tree · Finger tree · Metric tree · Cover tree · BK- tree · Doubly- chained tree · iDistance ·
Link- cut tree
Categories: Trees (structure) | String data structures
This page was last modified on 24 March 2011 at 07:51.
Text is available under the Creative Commons Attribution- ShareAlike License ; additional terms may apply. See Terms of Use for details.
Wikipedia® is a registered trademark of the Wikimedia Foundation, Inc., a non- profit organiz ation.
Contact us
Privacy policy
About Wikipedia
Disclaimers
PDFmyURL.com