<s>
In	O
computer	B-General_Concept
science	I-General_Concept
,	O
a	O
WAVL	B-Data_Structure
tree	I-Data_Structure
or	O
weak	O
AVL	O
tree	O
is	O
a	O
self-balancing	B-Data_Structure
binary	I-Data_Structure
search	I-Data_Structure
tree	I-Data_Structure
.	O
</s>
<s>
WAVL	B-Data_Structure
trees	I-Data_Structure
are	O
named	O
after	O
AVL	O
trees	O
,	O
another	O
type	O
of	O
balanced	O
search	O
tree	O
,	O
and	O
are	O
closely	O
related	O
both	O
to	O
AVL	O
trees	O
and	O
red	O
–	O
black	O
trees	O
,	O
which	O
all	O
fall	O
into	O
a	O
common	O
framework	O
of	O
rank	O
balanced	B-Data_Structure
trees	I-Data_Structure
.	O
</s>
<s>
Like	O
other	O
balanced	B-Data_Structure
binary	I-Data_Structure
search	I-Data_Structure
trees	I-Data_Structure
,	O
WAVL	B-Data_Structure
trees	I-Data_Structure
can	O
handle	O
insertion	O
,	O
deletion	O
,	O
and	O
search	O
operations	O
in	O
time	O
per	O
operation	O
.	O
</s>
<s>
WAVL	B-Data_Structure
trees	I-Data_Structure
are	O
designed	O
to	O
combine	O
some	O
of	O
the	O
best	O
properties	O
of	O
both	O
AVL	O
trees	O
and	O
red	O
–	O
black	O
trees	O
.	O
</s>
<s>
If	O
a	O
WAVL	B-Data_Structure
tree	I-Data_Structure
is	O
created	O
using	O
only	O
insertions	O
,	O
without	O
deletions	O
,	O
then	O
it	O
has	O
the	O
same	O
small	O
height	O
bound	O
that	O
an	O
AVL	O
tree	O
has	O
.	O
</s>
<s>
In	O
AVL	O
trees	O
,	O
each	O
deletion	O
may	O
require	O
a	O
logarithmic	O
number	O
of	O
tree	B-Data_Structure
rotation	I-Data_Structure
operations	O
,	O
while	O
red	O
–	O
black	O
trees	O
have	O
simpler	O
deletion	O
operations	O
that	O
use	O
only	O
a	O
constant	O
number	O
of	O
tree	B-Data_Structure
rotations	I-Data_Structure
.	O
</s>
<s>
WAVL	B-Data_Structure
trees	I-Data_Structure
,	O
like	O
red	O
–	O
black	O
trees	O
,	O
use	O
only	O
a	O
constant	O
number	O
of	O
tree	B-Data_Structure
rotations	I-Data_Structure
,	O
and	O
the	O
constant	O
is	O
even	O
better	O
than	O
for	O
red	O
–	O
black	O
trees	O
.	O
</s>
<s>
WAVL	B-Data_Structure
trees	I-Data_Structure
were	O
introduced	O
by	O
.	O
</s>
<s>
The	O
same	O
authors	O
also	O
provided	O
a	O
common	O
view	O
of	O
AVL	O
trees	O
,	O
WAVL	B-Data_Structure
trees	I-Data_Structure
,	O
and	O
red	O
–	O
black	O
trees	O
as	O
all	O
being	O
a	O
type	O
of	O
rank-balanced	O
tree	O
.	O
</s>
<s>
The	O
authors	O
of	O
introduce	O
the	O
rank	O
balanced	B-Data_Structure
trees	I-Data_Structure
framework	O
for	O
unifying	O
the	O
study	O
of	O
binary	O
search	O
tree	O
by	O
defining	O
the	O
rank	O
binary	O
tree	O
,	O
and	O
each	O
binary	O
search	O
tree	O
follows	O
by	O
specific	O
constraints	O
applied	O
to	O
the	O
rank	O
function	O
.	O
</s>
<s>
Left-leaning	O
red-black	O
rule	O
,	O
which	O
corresponds	O
to	O
Left-leaning	B-Data_Structure
red	I-Data_Structure
–	I-Data_Structure
black	I-Data_Structure
tree	I-Data_Structure
:	O
all	O
rank	O
differences	O
are	O
0	O
or	O
1	O
,	O
no	O
parent	O
of	O
a	O
0-child	O
is	O
a	O
0-child	O
,	O
and	O
no	O
0-child	O
of	O
a	O
0	O
,	O
1-node	O
is	O
right	O
.	O
</s>
<s>
Weak	O
AVL	O
rule	O
:	O
all	O
rank	O
differences	O
are	O
1	O
or	O
2	O
,	O
and	O
all	O
leaf	O
nodes	B-Data_Structure
have	O
rank	O
0	O
.	O
</s>
<s>
As	O
with	O
binary	O
search	O
trees	O
more	O
generally	O
,	O
a	O
WAVL	B-Data_Structure
tree	I-Data_Structure
consists	O
of	O
a	O
collection	O
of	O
nodes	B-Data_Structure
,	O
of	O
two	O
types	O
:	O
internal	O
nodes	B-Data_Structure
and	O
external	O
nodes	B-Data_Structure
.	O
</s>
<s>
These	O
nodes	B-Data_Structure
are	O
arranged	O
to	O
form	O
a	O
binary	O
tree	O
,	O
so	O
that	O
for	O
any	O
internal	O
node	O
the	O
parents	O
of	O
the	O
left	O
and	O
right	O
children	O
of	O
are	O
itself	O
.	O
</s>
<s>
The	O
external	O
nodes	B-Data_Structure
form	O
the	O
leaves	O
of	O
the	O
tree	O
.	O
</s>
<s>
What	O
distinguishes	O
WAVL	B-Data_Structure
trees	I-Data_Structure
from	O
other	O
types	O
of	O
binary	O
search	O
tree	O
is	O
its	O
use	O
of	O
ranks	O
.	O
</s>
<s>
Unlike	O
in	O
AVL	O
trees	O
,	O
where	O
ranks	O
are	O
defined	O
to	O
be	O
the	O
same	O
as	O
nodes	B-Data_Structure
 '	O
heights	O
,	O
ranks	O
do	O
not	O
always	O
equal	O
to	O
heights	O
in	O
WAVL	B-Data_Structure
trees	I-Data_Structure
.	O
</s>
<s>
Searching	O
for	O
a	O
key	O
in	O
a	O
WAVL	B-Data_Structure
tree	I-Data_Structure
is	O
much	O
the	O
same	O
as	O
in	O
any	O
balanced	B-Data_Structure
binary	I-Data_Structure
search	I-Data_Structure
tree	I-Data_Structure
data	O
structure	O
.	O
</s>
<s>
Inserting	O
an	O
internal	O
node	O
with	O
key	O
into	O
a	O
WAVL	B-Data_Structure
tree	I-Data_Structure
requires	O
a	O
search	O
for	O
in	O
the	O
tree	O
,	O
ending	O
at	O
an	O
external	O
node	O
,	O
then	O
a	O
replacement	O
of	O
that	O
external	O
node	O
with	O
the	O
new	O
internal	O
node	O
with	O
two	O
external	O
children	O
,	O
and	O
finally	O
a	O
rebalancing	O
of	O
the	O
tree	O
.	O
</s>
<s>
two	O
tree	B-Data_Structure
rotations	I-Data_Structure
,	O
with	O
associated	O
adjustments	O
to	O
rank-differences	O
,	O
</s>
<s>
Thus	O
,	O
overall	O
,	O
the	O
insertion	O
procedure	O
consists	O
of	O
a	O
search	O
,	O
the	O
creation	O
of	O
a	O
constant	O
number	O
of	O
new	O
nodes	B-Data_Structure
,	O
a	O
logarithmic	O
number	O
of	O
rank	O
changes	O
,	O
and	O
a	O
constant	O
number	O
of	O
tree	B-Data_Structure
rotations	I-Data_Structure
.	O
</s>
<s>
a	O
constant	O
number	O
of	O
new	O
nodes	B-Data_Structure
,	O
a	O
logarithmic	O
number	O
of	O
rank	O
changes	O
,	O
</s>
<s>
and	O
a	O
constant	O
number	O
of	O
tree	B-Data_Structure
rotations	I-Data_Structure
.	O
</s>
<s>
It	O
is	O
worthwhile	O
to	O
compare	O
the	O
result	O
of	O
a	O
delete	O
which	O
would	O
cause	O
rotations	O
at	O
multiple	O
levels	O
in	O
an	O
AVL	O
tree	O
with	O
the	O
rotation	O
and	O
rank	O
changes	O
performed	O
in	O
a	O
WAVL	B-Data_Structure
tree	I-Data_Structure
.	O
</s>
<s>
In	O
the	O
second	O
image	O
the	O
node	O
with	O
value	O
12	O
has	O
been	O
deleted	O
followed	O
by	O
a	O
right	O
rotation	O
and	O
assigning	O
of	O
all	O
external	O
nodes	B-Data_Structure
rank	O
zero	O
.	O
</s>
<s>
Each	O
search	O
,	O
insertion	O
,	O
or	O
deletion	O
in	O
a	O
WAVL	B-Data_Structure
tree	I-Data_Structure
involves	O
following	O
a	O
single	O
path	O
in	O
the	O
tree	O
and	O
performing	O
a	O
constant	O
number	O
of	O
steps	O
for	O
each	O
node	O
in	O
the	O
path	O
.	O
</s>
<s>
In	O
a	O
WAVL	B-Data_Structure
tree	I-Data_Structure
with	O
items	O
that	O
has	O
only	O
undergone	O
insertions	O
,	O
the	O
maximum	O
path	O
length	O
is	O
.	O
</s>
<s>
Therefore	O
,	O
in	O
either	O
case	O
,	O
the	O
worst-case	O
time	O
for	O
each	O
search	O
,	O
insertion	O
,	O
or	O
deletion	O
in	O
a	O
WAVL	B-Data_Structure
tree	I-Data_Structure
with	O
data	O
items	O
is	O
.	O
</s>
<s>
Adding	O
or	O
deleting	O
the	O
node	O
itself	O
is	O
constant	O
time	O
,	O
the	O
amount	O
of	O
rotations	O
is	O
always	O
at	O
most	O
constant	O
and	O
it	O
can	O
be	O
shown	O
that	O
the	O
total	O
amount	O
of	O
rank	O
changes	O
in	O
the	O
nodes	B-Data_Structure
is	O
linear	O
in	O
the	O
number	O
of	O
both	O
insertions	O
and	O
deletions	O
.	O
</s>
<s>
WAVL	B-Data_Structure
trees	I-Data_Structure
are	O
closely	O
related	O
to	O
both	O
AVL	O
trees	O
and	O
red	O
–	O
black	O
trees	O
.	O
</s>
<s>
Every	O
AVL	O
tree	O
can	O
have	O
ranks	O
assigned	O
to	O
its	O
nodes	B-Data_Structure
in	O
a	O
way	O
that	O
makes	O
it	O
into	O
a	O
WAVL	B-Data_Structure
tree	I-Data_Structure
.	O
</s>
<s>
And	O
every	O
WAVL	B-Data_Structure
tree	I-Data_Structure
can	O
have	O
its	O
nodes	B-Data_Structure
colored	O
red	O
and	O
black	O
(	O
and	O
its	O
ranks	O
reassigned	O
)	O
in	O
a	O
way	O
that	O
makes	O
it	O
into	O
a	O
red	O
–	O
black	O
tree	O
.	O
</s>
<s>
However	O
,	O
some	O
WAVL	B-Data_Structure
trees	I-Data_Structure
do	O
not	O
come	O
from	O
AVL	O
trees	O
in	O
this	O
way	O
and	O
some	O
red	O
–	O
black	O
trees	O
do	O
not	O
come	O
from	O
WAVL	B-Data_Structure
trees	I-Data_Structure
in	O
this	O
way	O
.	O
</s>
<s>
An	O
AVL	O
tree	O
is	O
a	O
kind	O
of	O
balanced	B-Data_Structure
binary	I-Data_Structure
search	I-Data_Structure
tree	I-Data_Structure
in	O
which	O
the	O
two	O
children	O
of	O
each	O
internal	O
node	O
must	O
have	O
heights	O
that	O
differ	O
by	O
at	O
most	O
one	O
.	O
</s>
<s>
Thus	O
,	O
the	O
height	O
function	O
of	O
an	O
AVL	O
tree	O
obeys	O
the	O
constraints	O
of	O
a	O
WAVL	B-Data_Structure
tree	I-Data_Structure
,	O
and	O
we	O
may	O
convert	O
any	O
AVL	O
tree	O
into	O
a	O
WAVL	B-Data_Structure
tree	I-Data_Structure
by	O
using	O
the	O
height	O
of	O
each	O
node	O
as	O
its	O
rank	O
.	O
</s>
<s>
The	O
key	O
difference	O
between	O
an	O
AVL	O
tree	O
and	O
a	O
WAVL	B-Data_Structure
tree	I-Data_Structure
arises	O
when	O
a	O
node	O
has	O
two	O
children	O
with	O
the	O
same	O
rank	O
or	O
height	O
.	O
</s>
<s>
In	O
contrast	O
,	O
in	O
a	O
WAVL	B-Data_Structure
tree	I-Data_Structure
,	O
if	O
a	O
node	O
has	O
two	O
children	O
of	O
the	O
same	O
rank	O
as	O
each	O
other	O
,	O
then	O
the	O
rank	O
of	O
can	O
be	O
either	O
or	O
.	O
</s>
<s>
This	O
is	O
because	O
rank	O
is	O
not	O
strictly	O
equal	O
to	O
height	O
in	O
WAVL	B-Data_Structure
tree	I-Data_Structure
.	O
</s>
<s>
This	O
greater	O
flexibility	O
in	O
ranks	O
also	O
leads	O
to	O
a	O
greater	O
flexibility	O
in	O
structures	O
:	O
some	O
WAVL	B-Data_Structure
trees	I-Data_Structure
cannot	O
be	O
made	O
into	O
AVL	O
trees	O
even	O
by	O
modifying	O
their	O
ranks	O
,	O
because	O
they	O
include	O
nodes	B-Data_Structure
whose	O
children	O
's	O
heights	O
differ	O
by	O
more	O
than	O
one	O
.	O
</s>
<s>
However	O
,	O
we	O
can	O
say	O
that	O
all	O
AVL	O
trees	O
are	O
WAVL	B-Data_Structure
trees	I-Data_Structure
.	O
</s>
<s>
AVL	O
trees	O
are	O
WAVL	B-Data_Structure
trees	I-Data_Structure
without	O
the	O
type	O
of	O
node	O
that	O
has	O
both	O
children	O
of	O
rank	O
difference	O
2	O
.	O
</s>
<s>
If	O
a	O
WAVL	B-Data_Structure
tree	I-Data_Structure
is	O
created	O
only	O
using	O
insertion	O
operations	O
,	O
then	O
its	O
structure	O
will	O
be	O
the	O
same	O
as	O
the	O
structure	O
of	O
an	O
AVL	O
tree	O
created	O
by	O
the	O
same	O
insertion	O
sequence	O
,	O
and	O
its	O
ranks	O
will	O
be	O
the	O
same	O
as	O
the	O
ranks	O
of	O
the	O
corresponding	O
AVL	O
tree	O
.	O
</s>
<s>
It	O
is	O
only	O
through	O
deletion	O
operations	O
that	O
a	O
WAVL	B-Data_Structure
tree	I-Data_Structure
can	O
become	O
different	O
from	O
an	O
AVL	O
tree	O
.	O
</s>
<s>
In	O
particular	O
this	O
implies	O
that	O
a	O
WAVL	B-Data_Structure
tree	I-Data_Structure
created	O
only	O
through	O
insertions	O
has	O
height	O
at	O
most	O
.	O
</s>
<s>
A	O
red	O
–	O
black	O
tree	O
is	O
a	O
balanced	B-Data_Structure
binary	I-Data_Structure
search	I-Data_Structure
tree	I-Data_Structure
in	O
which	O
each	O
node	O
has	O
a	O
color	O
(	O
red	O
or	O
black	O
)	O
,	O
satisfying	O
the	O
following	O
properties	O
:	O
</s>
<s>
External	O
nodes	B-Data_Structure
are	O
black	O
.	O
</s>
<s>
All	O
paths	O
from	O
the	O
root	O
to	O
an	O
external	O
node	O
have	O
equal	O
numbers	O
of	O
black	O
nodes	B-Data_Structure
.	O
</s>
<s>
Red	O
–	O
black	O
trees	O
can	O
equivalently	O
be	O
defined	O
in	O
terms	O
of	O
a	O
system	O
of	O
ranks	O
,	O
stored	O
at	O
the	O
nodes	B-Data_Structure
,	O
satisfying	O
the	O
following	O
requirements	O
(	O
different	O
than	O
the	O
requirements	O
for	O
ranks	O
in	O
WAVL	B-Data_Structure
trees	I-Data_Structure
)	O
:	O
</s>
<s>
In	O
the	O
other	O
direction	O
,	O
colors	O
can	O
be	O
converted	O
to	O
ranks	O
by	O
making	O
the	O
rank	O
of	O
a	O
black	O
node	O
equal	O
to	O
the	O
number	O
of	O
black	O
nodes	B-Data_Structure
on	O
any	O
path	O
to	O
an	O
external	O
node	O
,	O
and	O
by	O
making	O
the	O
rank	O
of	O
a	O
red	O
node	O
equal	O
to	O
its	O
parent	O
.	O
</s>
<s>
The	O
ranks	O
of	O
the	O
nodes	B-Data_Structure
in	O
a	O
WAVL	B-Data_Structure
tree	I-Data_Structure
can	O
be	O
converted	O
to	O
a	O
system	O
of	O
ranks	O
of	O
nodes	B-Data_Structure
,	O
obeying	O
the	O
requirements	O
for	O
red	O
–	O
black	O
trees	O
,	O
by	O
dividing	O
each	O
rank	O
by	O
two	O
and	O
rounding	O
up	O
to	O
the	O
nearest	O
integer	O
.	O
</s>
<s>
Because	O
of	O
this	O
conversion	O
,	O
for	O
every	O
WAVL	B-Data_Structure
tree	I-Data_Structure
there	O
exists	O
a	O
valid	O
red	O
–	O
black	O
tree	O
with	O
the	O
same	O
structure	O
.	O
</s>
<s>
Because	O
red	O
–	O
black	O
trees	O
have	O
maximum	O
height	O
,	O
the	O
same	O
is	O
true	O
for	O
WAVL	B-Data_Structure
trees	I-Data_Structure
.	O
</s>
<s>
However	O
,	O
there	O
exist	O
red	O
–	O
black	O
trees	O
that	O
cannot	O
be	O
given	O
a	O
valid	O
WAVL	B-Data_Structure
tree	I-Data_Structure
rank	O
function	O
.	O
</s>
<s>
Despite	O
the	O
fact	O
that	O
,	O
in	O
terms	O
of	O
their	O
tree	O
structures	O
,	O
WAVL	B-Data_Structure
trees	I-Data_Structure
are	O
special	O
cases	O
of	O
red	O
–	O
black	O
trees	O
,	O
their	O
update	O
operations	O
are	O
different	O
.	O
</s>
<s>
The	O
tree	B-Data_Structure
rotations	I-Data_Structure
used	O
in	O
WAVL	B-Data_Structure
tree	I-Data_Structure
update	O
operations	O
may	O
make	O
changes	O
that	O
would	O
not	O
be	O
permitted	O
in	O
a	O
red	O
–	O
black	O
tree	O
,	O
because	O
they	O
would	O
in	O
effect	O
cause	O
the	O
recoloring	O
of	O
large	O
subtrees	O
of	O
the	O
red	O
–	O
black	O
tree	O
rather	O
than	O
making	O
color	O
changes	O
only	O
on	O
a	O
single	O
path	O
in	O
the	O
tree	O
.	O
</s>
<s>
This	O
allows	O
WAVL	B-Data_Structure
trees	I-Data_Structure
to	O
perform	O
fewer	O
tree	B-Data_Structure
rotations	I-Data_Structure
per	O
deletion	O
,	O
in	O
the	O
worst	O
case	O
,	O
than	O
red-black	O
trees	O
.	O
</s>
