|
ADS
Algorithms and Data Structures
|
The ordered tree of any degree in \( 2 n + 1 \) bits by LOUDS, the level-order unary degree sequence of Jacobson (chapter 15, Compressed Data Structures, of Ferragina's book): a dummy root of degree 1 is put above the root, the nodes are visited by levels, and the degree \( d \) of each one is written in unary as \( 0^d 1 \), so that the code \( B \) has \( n \) 0s, one per node (each one is the child of somebody), and \( n + 1 \) 1s, one per node and the dummy root, i.e., \( 2 n + 1 \) bits. More...
#include "ADS/Contract.h"#include "ADS/succinct/BitVector.h"#include "ADS/succinct/RankSelect.h"#include <cstddef>#include <string_view>#include <vector>#include "ADS/succinct/impl/LoudsTree.tpp"Go to the source code of this file.
Classes | |
| class | ADS::LoudsTree |
| an ordered tree in \( 2 n + 1 \) bits by LOUDS, its nodes by levels More... | |
Namespaces | |
| namespace | ADS |
The ordered tree of any degree in \( 2 n + 1 \) bits by LOUDS, the level-order unary degree sequence of Jacobson (chapter 15, Compressed Data Structures, of Ferragina's book): a dummy root of degree 1 is put above the root, the nodes are visited by levels, and the degree \( d \) of each one is written in unary as \( 0^d 1 \), so that the code \( B \) has \( n \) 0s, one per node (each one is the child of somebody), and \( n + 1 \) 1s, one per node and the dummy root, i.e., \( 2 n + 1 \) bits.
The \( k \)-th 0 is the \( k \)-th node by levels, and the children of the \( k \)-th node are the 0s after the \( ( k + 1 ) \)-th 1, the 1 of the dummy root counting first; hence, with rank and select [see RankSelect.h], in \( O( 1 ) \) time:
with the nodes and the places counted from 1, as in the same chapter; here they count from 0 (the root is the node 0, at the place 0 of \( B \)), and the functions are leftmostChild() and rightSibling(), with the names of the TREE of the book [see Tree.h]. The \( i \)-th child is the first one plus \( i \), since the children of a node are consecutive in the order by levels, which a visit in depth does not give. LOUDS does not answer the size of a subtree nor the depth of a node, which the parentheses of a visit in depth do [see BPTree.h], at the price of a range min-max tree; it is the simplest of the succinct trees and the fastest for the navigation from the root down (Arroyuelo, Cánovas, Navarro and Sadakane), e.g., in the tries of the indices.
The contracts [see Contract.h]: the lists of the children describe a tree rooted at 0, \( B \) is a code of LOUDS (\( n \) 0s and \( n + 1 \) 1s, no prefix with more 0s than 1s before the last 1, an audit), and the nodes are in \( [ 0 , n ) \). The functions are defined in LoudsTree.tpp.