<s>
In	O
computer	B-General_Concept
science	I-General_Concept
,	O
an	O
optimal	B-Data_Structure
binary	I-Data_Structure
search	I-Data_Structure
tree	I-Data_Structure
(	O
Optimal	O
BST	O
)	O
,	O
sometimes	O
called	O
a	O
weight-balanced	O
binary	O
tree	O
,	O
is	O
a	O
binary	B-Language
search	I-Language
tree	I-Language
which	O
provides	O
the	O
smallest	O
possible	O
search	O
time	O
(	O
or	O
expected	O
search	O
time	O
)	O
for	O
a	O
given	O
sequence	O
of	O
accesses	O
(	O
or	O
access	O
probabilities	O
)	O
.	O
</s>
<s>
In	O
the	O
static	B-Data_Structure
optimality	I-Data_Structure
problem	O
,	O
the	O
tree	O
cannot	O
be	O
modified	O
after	O
it	O
has	O
been	O
constructed	O
.	O
</s>
<s>
In	O
the	O
dynamic	O
optimality	O
problem	O
,	O
the	O
tree	O
can	O
be	O
modified	O
at	O
any	O
time	O
,	O
typically	O
by	O
permitting	O
tree	B-Data_Structure
rotations	I-Data_Structure
.	O
</s>
<s>
The	O
splay	B-Data_Structure
tree	I-Data_Structure
is	O
conjectured	O
to	O
have	O
a	O
constant	O
competitive	B-Algorithm
ratio	I-Algorithm
compared	O
to	O
the	O
dynamically	O
optimal	O
tree	O
in	O
all	O
cases	O
,	O
though	O
this	O
has	O
not	O
yet	O
been	O
proven	O
.	O
</s>
<s>
In	O
the	O
static	B-Data_Structure
optimality	I-Data_Structure
problem	O
as	O
defined	O
by	O
Knuth	O
,	O
we	O
are	O
given	O
a	O
set	O
of	O
ordered	O
elements	O
and	O
a	O
set	O
of	O
probabilities	O
.	O
</s>
<s>
The	O
static	B-Data_Structure
optimality	I-Data_Structure
problem	O
is	O
the	O
optimization	O
problem	O
of	O
finding	O
the	O
binary	B-Language
search	I-Language
tree	I-Language
that	O
minimizes	O
the	O
expected	O
search	O
time	O
,	O
given	O
the	O
probabilities	O
.	O
</s>
<s>
As	O
the	O
number	O
of	O
possible	O
trees	B-Application
on	O
a	O
set	O
of	O
elements	O
is	O
,	O
which	O
is	O
exponential	O
in	O
,	O
brute-force	B-Algorithm
search	I-Algorithm
is	O
not	O
usually	O
a	O
feasible	O
solution	O
.	O
</s>
<s>
In	O
1971	O
,	O
Knuth	O
published	O
a	O
relatively	O
straightforward	O
dynamic	B-Algorithm
programming	I-Algorithm
algorithm	O
capable	O
of	O
constructing	O
the	O
statically	O
optimal	O
tree	O
in	O
only	O
O(n2 )	O
time	O
.	O
</s>
<s>
In	O
this	O
work	O
,	O
Knuth	O
extended	O
and	O
improved	O
the	O
dynamic	B-Algorithm
programming	I-Algorithm
algorithm	O
by	O
Edgar	O
Gilbert	O
and	O
Edward	O
F	O
.	O
Moore	O
introduced	O
in	O
1958	O
.	O
</s>
<s>
Gilbert	O
's	O
and	O
Moore	O
's	O
algorithm	O
required	O
time	O
and	O
space	O
and	O
was	O
designed	O
for	O
a	O
particular	O
case	O
of	O
optimal	B-Data_Structure
binary	I-Data_Structure
search	I-Data_Structure
trees	I-Data_Structure
construction	O
(	O
known	O
as	O
optimal	O
alphabetic	O
tree	O
problem	O
)	O
that	O
considers	O
only	O
the	O
probability	O
of	O
unsuccessful	O
searches	O
,	O
that	O
is	O
,	O
.	O
</s>
<s>
Knuth	O
's	O
work	O
relied	O
upon	O
the	O
following	O
insight	O
:	O
the	O
static	B-Data_Structure
optimality	I-Data_Structure
problem	O
exhibits	O
optimal	B-Algorithm
substructure	I-Algorithm
;	O
that	O
is	O
,	O
if	O
a	O
certain	O
tree	O
is	O
statically	O
optimal	O
for	O
a	O
given	O
probability	O
distribution	O
,	O
then	O
its	O
left	O
and	O
right	O
subtrees	B-Application
must	O
also	O
be	O
statically	O
optimal	O
for	O
their	O
appropriate	O
subsets	O
of	O
the	O
distribution	O
(	O
known	O
as	O
monotonicity	O
property	O
of	O
the	O
roots	O
)	O
.	O
</s>
<s>
Let	O
E	O
be	O
the	O
weighted	O
path	O
length	O
of	O
a	O
binary	O
tree	O
,	O
be	O
the	O
weighted	O
path	O
length	O
of	O
its	O
left	O
subtree	B-Application
,	O
and	O
be	O
the	O
weighted	O
path	O
length	O
of	O
its	O
right	O
subtree	B-Application
.	O
</s>
<s>
Observe	O
that	O
when	O
either	O
subtree	B-Application
is	O
attached	O
to	O
the	O
root	O
,	O
the	O
depth	O
of	O
each	O
of	O
its	O
elements	O
(	O
and	O
thus	O
each	O
of	O
its	O
search	O
paths	O
)	O
is	O
increased	O
by	O
one	O
.	O
</s>
<s>
This	O
means	O
that	O
the	O
difference	O
in	O
weighted	O
path	O
length	O
between	O
a	O
tree	O
and	O
its	O
two	O
subtrees	B-Application
is	O
exactly	O
the	O
sum	O
of	O
every	O
single	O
probability	O
in	O
the	O
tree	O
,	O
leading	O
to	O
the	O
following	O
recurrence	O
:	O
</s>
<s>
This	O
recurrence	O
leads	O
to	O
a	O
natural	O
dynamic	B-Algorithm
programming	I-Algorithm
solution	O
.	O
</s>
<s>
In	O
addition	O
to	O
its	O
dynamic	B-Algorithm
programming	I-Algorithm
algorithm	O
,	O
Knuth	O
proposed	O
two	O
heuristics	O
(	O
or	O
rules	O
)	O
to	O
produce	O
nearly	O
(	O
approximation	O
of	O
)	O
optimal	B-Data_Structure
binary	I-Data_Structure
search	I-Data_Structure
trees	I-Data_Structure
.	O
</s>
<s>
Studying	O
nearly	O
optimal	B-Data_Structure
binary	I-Data_Structure
search	I-Data_Structure
trees	I-Data_Structure
was	O
necessary	O
since	O
Knuth	O
's	O
algorithm	O
time	O
and	O
space	O
complexity	O
can	O
be	O
prohibitive	O
when	O
is	O
substantially	O
large	O
.	O
</s>
<s>
Rule	O
I	O
(	O
Root-max	O
)	O
:	O
Place	O
the	O
most	O
frequently	O
occurring	O
name	O
at	O
the	O
root	O
of	O
the	O
tree	O
,	O
then	O
proceed	O
similarly	O
on	O
the	O
subtrees	B-Application
.	O
</s>
<s>
Rule	O
II	O
(	O
Bisection	O
)	O
:	O
Choose	O
the	O
root	O
so	O
as	O
to	O
equalize	O
the	O
total	O
weight	O
of	O
the	O
left	O
and	O
right	O
subtree	B-Application
as	O
much	O
as	O
possible	O
,	O
then	O
proceed	O
similarly	O
on	O
the	O
subtrees	B-Application
.	O
</s>
<s>
Knuth	O
's	O
heuristics	O
implements	O
nearly	O
optimal	B-Data_Structure
binary	I-Data_Structure
search	I-Data_Structure
trees	I-Data_Structure
in	O
time	O
and	O
space	O
.	O
</s>
<s>
While	O
the	O
O(n2 )	O
time	O
taken	O
by	O
Knuth	O
's	O
algorithm	O
is	O
substantially	O
better	O
than	O
the	O
exponential	O
time	O
required	O
for	O
a	O
brute-force	B-Algorithm
search	I-Algorithm
,	O
it	O
is	O
still	O
too	O
slow	O
to	O
be	O
practical	O
when	O
the	O
number	O
of	O
elements	O
in	O
the	O
tree	O
is	O
very	O
large	O
.	O
</s>
<s>
Mehlhorn	O
's	O
major	O
results	O
state	O
that	O
only	O
one	O
of	O
Knuth	O
's	O
heuristics	O
(	O
Rule	O
II	O
)	O
always	O
produces	O
nearly	O
optimal	B-Data_Structure
binary	I-Data_Structure
search	I-Data_Structure
trees	I-Data_Structure
.	O
</s>
<s>
On	O
the	O
other	O
hand	O
,	O
the	O
root-max	O
rule	O
could	O
often	O
lead	O
to	O
very	O
"	O
bad	O
"	O
search	O
trees	B-Application
based	O
on	O
the	O
following	O
simple	O
argument	O
.	O
</s>
<s>
The	O
algorithm	O
follows	O
the	O
same	O
idea	O
of	O
the	O
bisection	O
rule	O
by	O
choosing	O
the	O
tree	O
's	O
root	O
to	O
balance	O
the	O
total	O
weight	O
(	O
by	O
probability	O
)	O
of	O
the	O
left	O
and	O
right	O
subtrees	B-Application
most	O
closely	O
.	O
</s>
<s>
And	O
the	O
strategy	O
is	O
then	O
applied	O
recursively	O
on	O
each	O
subtree	B-Application
.	O
</s>
<s>
That	O
this	O
strategy	O
produces	O
a	O
good	O
approximation	O
can	O
be	O
seen	O
intuitively	O
by	O
noting	O
that	O
the	O
weights	O
of	O
the	O
subtrees	B-Application
along	O
any	O
path	O
form	O
something	O
very	O
close	O
to	O
a	O
geometrically	O
decreasing	O
sequence	O
.	O
</s>
<s>
A	O
later	O
simplification	O
by	O
Garsia	O
and	O
Wachs	O
,	O
the	O
Garsia	B-Data_Structure
–	I-Data_Structure
Wachs	I-Data_Structure
algorithm	I-Data_Structure
,	O
performs	O
the	O
same	O
comparisons	O
in	O
the	O
same	O
order	O
.	O
</s>
<s>
The	O
algorithm	O
works	O
by	O
using	O
a	O
greedy	B-Algorithm
algorithm	I-Algorithm
to	O
build	O
a	O
tree	O
that	O
has	O
the	O
optimal	O
height	O
for	O
each	O
leaf	O
,	O
but	O
is	O
out	O
of	O
order	O
,	O
and	O
then	O
constructing	O
another	O
binary	B-Language
search	I-Language
tree	I-Language
with	O
the	O
same	O
heights	O
.	O
</s>
<s>
The	O
problem	O
was	O
first	O
introduced	O
implicitly	O
by	O
Sleator	O
and	O
Tarjan	O
in	O
their	O
paper	O
on	O
splay	B-Data_Structure
trees	I-Data_Structure
,	O
but	O
Demaine	O
et	O
al	O
.	O
</s>
<s>
Perform	O
a	O
single	O
rotation	B-Data_Structure
on	O
the	O
current	O
node	O
and	O
its	O
parent	O
.	O
</s>
<s>
While	O
it	O
is	O
impossible	O
to	O
implement	O
this	O
"	O
God	O
's	O
algorithm	O
"	O
without	O
foreknowledge	O
of	O
exactly	O
what	O
the	O
access	O
sequence	O
will	O
be	O
,	O
we	O
can	O
define	O
OPT(X )	O
as	O
the	O
number	O
of	O
operations	O
it	O
would	O
perform	O
for	O
an	O
access	O
sequence	O
X	O
,	O
and	O
we	O
can	O
say	O
that	O
an	O
algorithm	O
is	O
dynamically	O
optimal	O
if	O
,	O
for	O
any	O
X	O
,	O
it	O
performs	O
X	O
in	O
time	O
O(OPT(X )	O
)	O
(	O
that	O
is	O
,	O
it	O
has	O
a	O
constant	O
competitive	B-Algorithm
ratio	I-Algorithm
)	O
.	O
</s>
<s>
The	O
splay	B-Data_Structure
tree	I-Data_Structure
is	O
a	O
form	O
of	O
binary	B-Language
search	I-Language
tree	I-Language
invented	O
in	O
1985	O
by	O
Daniel	O
Sleator	O
and	O
Robert	O
Tarjan	O
on	O
which	O
the	O
standard	O
search	O
tree	O
operations	O
run	O
in	O
amortized	O
time	O
.	O
</s>
<s>
That	O
is	O
,	O
a	O
splay	B-Data_Structure
tree	I-Data_Structure
is	O
believed	O
to	O
perform	O
any	O
sufficiently	O
long	O
access	O
sequence	O
X	O
in	O
time	O
O(OPT(X )	O
)	O
.	O
</s>
<s>
The	O
tango	B-Data_Structure
tree	I-Data_Structure
is	O
a	O
data	O
structure	O
proposed	O
in	O
2004	O
by	O
Erik	O
Demaine	O
and	O
others	O
which	O
has	O
been	O
proven	O
to	O
perform	O
any	O
sufficiently-long	O
access	O
sequence	O
X	O
in	O
time	O
.	O
</s>
<s>
While	O
this	O
is	O
not	O
dynamically	O
optimal	O
,	O
the	O
competitive	B-Algorithm
ratio	I-Algorithm
of	O
is	O
still	O
very	O
small	O
for	O
reasonable	O
values	O
of	O
n	O
.	O
</s>
<s>
In	O
2013	O
,	O
John	O
Iacono	O
published	O
a	O
paper	O
which	O
uses	O
the	O
geometry	O
of	O
binary	B-Language
search	I-Language
trees	I-Language
to	O
provide	O
an	O
algorithm	O
which	O
is	O
dynamically	O
optimal	O
if	O
any	O
binary	B-Language
search	I-Language
tree	I-Language
algorithm	O
is	O
dynamically	O
optimal	O
.	O
</s>
<s>
Unlike	O
splay	B-Data_Structure
trees	I-Data_Structure
and	O
tango	B-Data_Structure
trees	I-Data_Structure
,	O
Iacono	O
's	O
data	O
structure	O
is	O
not	O
known	O
to	O
be	O
implementable	O
in	O
constant	O
time	O
per	O
access	O
sequence	O
step	O
,	O
so	O
even	O
if	O
it	O
is	O
dynamically	O
optimal	O
,	O
it	O
could	O
still	O
be	O
slower	O
than	O
other	O
search	O
tree	B-Application
data	I-Application
structures	I-Application
by	O
a	O
non-constant	O
factor	O
.	O
</s>
<s>
The	O
interleave	O
lower	O
bound	O
is	O
an	O
asymptotic	B-General_Concept
lower	I-General_Concept
bound	I-General_Concept
on	O
dynamic	O
optimality	O
.	O
</s>
