|
ADS
Algorithms and Data Structures
|
the join of the AVL trees; A gives also height( t ), -1 for nil, which connect() keeps 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 AVL trees \( l \) and \( r \) with \( m \) between them, in \( O( | h( l ) - h( r ) | + 1 ) \) time | |
| static Node * | joinRight (Node *l, Node *m, Node *r) |
| the join when \( l \) is higher than \( r \) by more than 1, by the right spine of \( l \) | |
| static Node * | joinLeft (Node *l, Node *m, Node *r) |
| the join when \( r \) is higher than \( l \) by more than 1, the mirror of joinRight() | |
the join of the AVL trees; A gives also height( t ), -1 for nil, which connect() keeps
| using ADS::AVLJoin< A >::Node = typename A::Node |
the type of the nodes
|
static |
the join of the AVL trees \( l \) and \( r \) with \( m \) between them, in \( O( | h( l ) - h( r ) | + 1 ) \) time
In pseudocode (Blelloch, Ferizovic and Sun, beyond the book), \( h \) the height, and the mirror of joinRight() when \( R \) is higher:
\[\class{pseudocode}{\begin{array}{r@{\quad}l} 1 & \textbf{function}\ \mathrm{join}( L , k , R ) \cr 2 & \quad \textbf{if}\ h( L ) > h( R ) + 1\ \textbf{then return} \ \mathrm{joinRight}( L , k , R ) \cr 3 & \quad \textbf{if}\ h( R ) > h( L ) + 1\ \textbf{then return} \ \mathrm{joinLeft}( L , k , R ) \cr 4 & \quad \textbf{return}\ \mathrm{node}( L , k , R ) \cr 5 & \textbf{function}\ \mathrm{joinRight}( L , k , R ) \cr 6 & \quad ( l , k' , c ) \gets \mathrm{expose}( L ) \cr 7 & \quad \textbf{if}\ h( c ) \le h( R ) + 1\ \textbf{then} \cr 8 & \qquad T' \gets \mathrm{node}( c , k , R ) \cr 9 & \qquad \textbf{if}\ h( T' ) \le h( l ) + 1\ \textbf{then return} \ \mathrm{node}( l , k' , T' ) \cr 10 & \qquad \textbf{return}\ \mathrm{rotateLeft}( \mathrm{node}( l , k' , \mathrm{rotateRight}( T' ) ) ) \cr 11 & \quad T' \gets \mathrm{joinRight}( c , k , R );\ T'' \gets \mathrm{node}( l , k' , T' ) \cr 12 & \quad \textbf{if}\ h( T' ) \le h( l ) + 1\ \textbf{then return}\ T'' \cr 13 & \quad \textbf{return}\ \mathrm{rotateLeft}( T'' ) \end{array}} \]
|
static |
the join when \( r \) is higher than \( l \) by more than 1, the mirror of joinRight()
|
static |
the join when \( l \) is higher than \( r \) by more than 1, by the right spine of \( l \)