|
ADS
Algorithms and Data Structures
|
The Patricia trie of a static dictionary of strings in succinct space, beyond the book: the compacted trie of the strings [see PatriciaTrie.h for the trie with pointers] coded by the degrees of its nodes in depth (DFUDS) of Benoit, Demaine, Munro, Raman, Raman and Rao, with the first character of each edge in a byte and the rest of its label in a string apart, and a string mapped to its rank in the lexicographic order (see Ordered dictionaries and tries). More...
#include "ADS/Contract.h"#include "ADS/string/PrefixSearch.h"#include "ADS/succinct/BalancedParentheses.h"#include "ADS/succinct/CompactRankSelect.h"#include "ADS/succinct/EliasFano.h"#include <cstddef>#include <string>#include <string_view>#include <utility>#include <vector>#include "ADS/dictionary/impl/SuccinctPatriciaTrie.tpp"Go to the source code of this file.
Classes | |
| class | ADS::SuccinctPatriciaTrie |
| the compacted trie of a sorted dictionary of strings in DFUDS, the strings numbered by their lexicographic rank More... | |
Namespaces | |
| namespace | ADS |
The Patricia trie of a static dictionary of strings in succinct space, beyond the book: the compacted trie of the strings [see PatriciaTrie.h for the trie with pointers] coded by the degrees of its nodes in depth (DFUDS) of Benoit, Demaine, Munro, Raman, Raman and Rao, with the first character of each edge in a byte and the rest of its label in a string apart, and a string mapped to its rank in the lexicographic order (see Ordered dictionaries and tries).
The \( N \) nodes of the compacted trie (at most \( 2 n \) for \( n \) strings, since each inner node but the root branches) are visited in depth, the children of a node by their first character, and the node of \( d \) children is written as \( d \) open parentheses and one closed one, after an open parenthesis that balances the whole: \( 2 N \) bits, in which the node of rank \( v \) in the visit begins after the \( v \)-th closed parenthesis, and with the matching of the parentheses [see BalancedParentheses.h] the \( i \)-th child of the node at the place \( p \), of degree \( d \), begins after the closed parenthesis that matches the open one at \( p + d - 1 - i \); the first characters of the children of a node are consecutive, in the order of the open parentheses, so that the child of a character is found by a binary search on at most \( \sigma \) bytes. The visit in depth numbers the nodes of a subtree consecutively, and the subtree of the node at \( p \) ends where the excess first falls below the one at \( p - 1 \) (forwardSearch()); hence, with a vector of bits that marks the nodes where a string ends, the strings are numbered in the lexicographic order (a node before its subtree, and the subtrees by their first characters) and those of a subtree, i.e., those with a given prefix, form a range of ranks.
The space is \( 2 N + o( N ) \) bits for the parentheses with their range min-max tree, \( 8 ( N - 1 ) \) for the first characters, \( 2 N + o( N ) \) for the marks of the ends and of the rests, and the rests of the labels, one after the other, with their places by Elias-Fano [see EliasFano.h]; against the pointer trie, where a node takes some tens of bytes, and against the front coding with buckets [see RearCoding.h], which on strings with long shared prefixes may be smaller still, since the rests of the labels are not compressed. A lookup of \( Q \) walks down \( O( | Q | ) \) nodes, each in \( O( \log \sigma ) \) time besides a rank, a select of Elias-Fano for the rest of its label and, but for the first child, whose code follows the closed parenthesis of the node, a findClose(); the closed parenthesis of a node is found by the trailing ones of the words from its place. access() walks up from the node of the string by findOpen().
The contracts [see Contract.h]: the strings sorted, with no string twice (an audit); access() needs \( i < n \); the audit of the construction is that access() and lookup() invert each other. The functions are defined in SuccinctPatriciaTrie.tpp.