select(i)
returns the node with rank \(i\).rank(x)
returns the rank of node x
.select
to find the median of a data set.x
has a field x.size
equal to the number of descendants of x
.x
equalsNIL
node with NIL.size
= 0.rank(x)
: Climb up x
’s access path, computing the above sum.select(i)
: Starting at the root, descend to the node of rank i
by maintaining the rank of the node we are at (using the above sum) and descending left if the rank is too big, right if too small.insert
: When adding a new leaf x
, increase u.size
by 1 for every node u
on x
’s access path.delete
: When splicing out node y
, decrease u.size
by 1 for every node u
on y
’s access path.insert
or delete
).It is easy to compute x.size
for any node x
using the identity
x.size = 1 + x.left.size + x.right.size
join(T1, x, T2)
: where T1
& T2
are search trees, and x
is a node,x.key
is \(\ge\) every key in T1
, and \(\le\) every key in T2
.join
returns a search tree consisting of the keys in T1
, T2
, and x
.T1
and T2
are destroyed.split(T, x)
: where T
is a search tree containing node x
.split
returns search trees T1
, T2
and node x
, where T1
contains all nodes in T
with key
\(<\) x.key
, and T2
contains all nodes in T
with key
\(>\) x.key
.join
, split
, and all previous operations in time \(O(\log n)\) worst-case time per operation.join
is to use it to find a minimum spanning tree.