|
ADS
Algorithms and Data Structures
|
The wavelet tree shaped by the code of Huffman of Mäkinen and Navarro: a sequence \( x_0 , \ldots , x_{n-1} \) of symbols of \( [ 0 , \sigma ) \) in \( n ( H_0 + 1 ) \) bits and a little more, with access, rank and select of any symbol in time proportional to the length of its code, \( H_0 + 1 \) steps on average, against the \( \lceil \log_2 \sigma \rceil \) levels of the balanced tree and of the wavelet matrix [see WaveletMatrix.h], which take \( n \lceil \log_2 \sigma \rceil \) bits. More...
#include "ADS/Contract.h"#include "ADS/external/MappedFile.h"#include "ADS/parallel/Executor.h"#include "ADS/succinct/BitVector.h"#include "ADS/succinct/CompactRankSelect.h"#include "ADS/succinct/RankSelect.h"#include <algorithm>#include <cstddef>#include <cstdint>#include <span>#include <string_view>#include <type_traits>#include <utility>#include <vector>#include "ADS/succinct/impl/HuffmanWaveletTree.tpp"Go to the source code of this file.
Classes | |
| class | ADS::HuffmanWaveletTree< RS > |
| a static sequence of symbols in about \( H_0 + 1 \) bits each, with access, rank and select in time proportional to the length of a code; RS is the rank and select of its bits, RankSelect or CompactRankSelect More... | |
Namespaces | |
| namespace | ADS |
The wavelet tree shaped by the code of Huffman of Mäkinen and Navarro: a sequence \( x_0 , \ldots , x_{n-1} \) of symbols of \( [ 0 , \sigma ) \) in \( n ( H_0 + 1 ) \) bits and a little more, with access, rank and select of any symbol in time proportional to the length of its code, \( H_0 + 1 \) steps on average, against the \( \lceil \log_2 \sigma \rceil \) levels of the balanced tree and of the wavelet matrix [see WaveletMatrix.h], which take \( n \lceil \log_2 \sigma \rceil \) bits.
The symbol \( c \) has the canonical code of Huffman of its frequency in \( x \), of length \( \ell_c \), its bits from the highest; the tree is the trie of the codes, and its internal node \( v \), reached by the prefix \( \pi_v \), keeps the bit after \( \pi_v \) of the code of each item whose code starts with \( \pi_v \), in the order of the sequence. The bits of all the nodes are one vector \( B \) with rank and select [see RankSelect.h and CompactRankSelect.h], the node \( v \) from the place \( o_v \) with \( R_v = \mathrm{rank}_1( B , o_v ) \) kept; the item of place \( i \) in the node \( v \) moves to the place
\[ i' = \mathrm{rank}_b( B , o_v + i ) - \mathrm{rank}_b( B , o_v ) \]
of its child by the bit \( b = B[ o_v + i ] \), so that a descent along the code of \( c \) gives access( i ), with the rank of the symbol found (accessRank(), the LF-mapping of an FM-index in one descent), and \( \mathrm{rank}_c( i ) \), one rank a step, while \( \mathrm{select}_c( k ) \) climbs from the leaf of \( c \) by one select a step,
\[ k' = \mathrm{select}_b( B , \mathrm{rank}_b( B , o_v ) + k ) - o_v + 1 . \]
The bits of \( B \) are \( \sum_c f_c \ell_c < n ( H_0 + 1 ) \) for the frequencies \( f_c \), by the bound of the code of Huffman, plus the directory of rank and select, 25% of them with RankSelect without the inventories of select and about 50% with them, 3.125% with CompactRankSelect besides less than 0.8% for the samples of each select (the parameter RS: time against bits), and \( O( \sigma ) \) words of the tree and of the codes.
The contracts [see Contract.h]: the places and the counts are in range, select asks for an occurrence that exists (and the tree was built with select); the audit of the construction is that access() gives back each item. The functions are defined in HuffmanWaveletTree.tpp.