|
ADS
Algorithms and Data Structures
|
the join of the trees balanced by weight, with \( \alpha = 0.29 \) More...
#include <ADS/tree/JoinAlgorithms.h>
Public types | |
| using | Node = typename A::Node |
| the type of the nodes | |
Static public member functions | |
| static Node * | join (Node *l, Node *m, Node *r) |
| the join of the trees \( l \) and \( r \) balanced by weight with \( m \) between them, in \( O( | \log w( l ) - \log w( r ) | + 1 ) \) time | |
| static Node * | joinRight (Node *l, Node *m, Node *r) |
| the join when \( l \) is heavier than \( r \) beyond the balance, by the right spine of \( l \) | |
| static Node * | joinLeft (Node *l, Node *m, Node *r) |
| the join when \( r \) is heavier than \( l \) beyond the balance, the mirror of joinRight() | |
| static bool | like (std::size_t a, std::size_t b) |
| whether the weights \( a \) and \( b \) may be the two sides of a node: \( \alpha ( a + b ) \le \min( a , b ) \) | |
| static std::size_t | weight (const Node *t) |
| the weight of \( t \), its size plus 1 | |
Static public attributes | |
| static constexpr std::size_t | kAlphaNum = 29 |
| \( \alpha \), up | |
| static constexpr std::size_t | kAlphaDen = 100 |
| and down | |
the join of the trees balanced by weight, with \( \alpha = 0.29 \)
| using ADS::WeightBalancedJoin< A >::Node = typename A::Node |
the type of the nodes
|
static |
the join of the trees \( l \) and \( r \) balanced by weight with \( m \) between them, in \( O( | \log w( l ) - \log w( r ) | + 1 ) \) time
In pseudocode (Blelloch, Ferizovic and Sun, after Nievergelt and Reingold, beyond the book), \( w \) the weight, \( \mathrm{like}( a , b ) \) true if \( \alpha ( a + b ) \le \min( a , b ) \), and the mirror of joinRight() when \( R \) is heavier:
\[\class{pseudocode}{\begin{array}{r@{\quad}l} 1 & \textbf{function}\ \mathrm{join}( L , k , R ) \cr 2 & \quad \textbf{if}\ \mathrm{like}( w( L ) , w( R ) )\ \textbf{then return} \ \mathrm{node}( L , k , R ) \cr 3 & \quad \textbf{if}\ w( L ) > w( R )\ \textbf{then return} \ \mathrm{joinRight}( L , k , R ) \cr 4 & \quad \textbf{return}\ \mathrm{joinLeft}( L , k , R ) \cr 5 & \textbf{function}\ \mathrm{joinRight}( L , k , R ) \cr 6 & \quad \textbf{if}\ \mathrm{like}( w( L ) , w( R ) )\ \textbf{then return} \ \mathrm{node}( L , k , R ) \cr 7 & \quad ( l , k' , c ) \gets \mathrm{expose}( L );\ T' \gets \mathrm{joinRight}( c , k , R ) \cr 8 & \quad \textbf{if}\ \mathrm{like}( w( l ) , w( T' ) )\ \textbf{then return} \ \mathrm{node}( l , k' , T' ) \cr 9 & \quad ( l_1 , r_1 ) \gets \text{the children of } T' \cr 10 & \quad \textbf{if}\ \mathrm{like}( w( l ) , w( l_1 ) )\ \textbf{and} \ \mathrm{like}( w( l ) + w( l_1 ) , w( r_1 ) )\ \textbf{then} \cr 11 & \qquad \textbf{return}\ \mathrm{rotateLeft}( \mathrm{node}( l , k' , T' ) ) \cr 12 & \quad \textbf{return}\ \mathrm{rotateLeft}( \mathrm{node}( l , k' , \mathrm{rotateRight}( T' ) ) ) \end{array}} \]
|
static |
the join when \( r \) is heavier than \( l \) beyond the balance, the mirror of joinRight()
|
static |
the join when \( l \) is heavier than \( r \) beyond the balance, by the right spine of \( l \)
|
static |
whether the weights \( a \) and \( b \) may be the two sides of a node: \( \alpha ( a + b ) \le \min( a , b ) \)
|
static |
the weight of \( t \), its size plus 1
|
staticconstexpr |
and down
|
staticconstexpr |
\( \alpha \), up