Download Deterministic Skip Lists

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts

Array data structure wikipedia , lookup

Lattice model (finance) wikipedia , lookup

Quadtree wikipedia , lookup

Interval tree wikipedia , lookup

Red–black tree wikipedia , lookup

Binary tree wikipedia , lookup

Linked list wikipedia , lookup

B-tree wikipedia , lookup

Binary search tree wikipedia , lookup

Transcript
Chapter
43
Deterministic
J. Ian
Thomas
Munrot
Skip
Lists*
Papadakist
Robert
Abstract
trees.
Reexplore
Denenberg,
techniques
guarantee
basic
idea
above
precisely
that
Thedesired
that
code, whereas
of memory
physical
of time
Our
and space with
we feel, inherently
simpler
suited
of elements
when
taken
the
of
the
nodes
system
tree
from
in
schemes,
first
and,
principles.
We
address
structure
delete
to
and
worst
the
classic
support
the
find-closest
case.
There
problem
are several
in a skip
over
all
outcomes
average
cost
for
the
B-tree
tree,
the
red-black
tree
[4],
but
which
memory
applications
practice.
Our
in
Evidently,
to implement
general
the
question
and
“how
neurons
grammer
may
be, we restrict
for
hard
or complicated
programmer”.
a data
in
the
hard
structure?)’
head
problem
bound
pro-
the
latter
we feel
with
by
the
Pugh
[8]
skip
as
list,
an
that
alternative
Waterloo,
Princeton,
of Computer
Science,
University
of
Computer
in
Princeton
the
search
new
keys).
to
and
probability
list
average
in
is taken
m + 6)(1)
skip
node
the
element
p is the
the
the
decides
be
insert
to
inserted.
and
delete
skip
any
list
by
behaviour
of at most
worst
that
which
and
suited
allocation
in
this
requirement
case update
n)
worst
over
cost,
initial
cost.
or a total
6n pointers
The
(e.g.
increase
form
aa we are given
of at
version
the
buddy
BSD
Unix),
in
having
this
a to-
version
2.3n
in which
is employed
the
discipline
case update
coding.
case
of at most
to @(lg n) with
The
is no
ver-
worst
our
in one version,
there
etc.)
deterministic
a total
to an environment
version,
is
Thus
logarithmic
a @(lg n)
requires
system
list
[8].
red-black,
demonstrating
of easier
skip
operation.
in another.
advantage
the
a firm
several
is improved
6n pointers
case insert
as functions
Pugh
(AVL,
have
haa a @(lg2
2 .3n pointers
if
by
wants
individual
form,
update
since
schemes
we present
and update
worst
even
of one who
We begin
memory
367
for
paper,
tree
insert
the
unbounded
linear
cost.
the
average
low,
as suggested
simplest
is ideally
NJ 08544, USA
search
This
has
the
are
remain
2n pointers
most
University,
lists
level,
refuge
of the
its
age
Science,
they
bound
recently
of Waterloo,
of
that
skip
at some
In this
Ont N2L 3G1, Canada
t Department
and
upper
form
*This research was supported in part by the National Science
and Engineering Research Council of Canada under grant No. A8237, the Information
Technology Research Centre of Ontario,
and the National
Science Foundation
under Grant No. CCR8918152
build
average
all search
log~
to
mth
about
average
over
where
to
sense
this
aver-age
~
costs are technically
the
sions
to
and
that
on the
of the
and
this
n +
about
the fact
balanced
is a new
was
hold
the
remain
tal
t DePmtment
n,
the
or
of the
for
capped
to
in logarithmic
for
to what
of
is it
height
Despite
main
square
“how
fiips
respectively,
used
results
search
start
introduced
Similar
of the
log;
list
costs .
bal-
bound.
We
the
and update
too
dictionary
ourselves
used
coin
increase
2-3
are
n + @(l)
the
computational
becomes
as a lower
of which
research)
such
the
[8,7]
flips)
(where
of coin
are
search
(where
of coin
search
skip
depends
makes
the
a
the insertion
of the
therefore
for
in leading
is, given
and
but
of n elements
of n elements
costs
costs
then
fire
that
case the
are rarely
mean
must
the
Intriguing
upper
seem
~ log:
in the
solutions,
special
all
“root
implement
to solve
time?”
its
etc.,
(non
they
for
understand
many
[2] and
list
all outcomes
insert,
time
list
These
a data
search,
well-known
[1], the
trees,
of
in logarithmic
tree
search
designing
operations
value
AVL
anced
of
It
cost
element
over
Introduction
flips.
average
and
data
structures,
that
list
shape
list
data
in nature,
determined,
is taken
a skip
1
coin
the
other
in a skip
the
Lewis
introductory
the skip
Unlike
values,
is not
of
about
structure;
their
is probabilistic
of these
outcomes
tree.
to be stored
be formed
talk
data
in
[5] introduce
search
list
sequence
be
simple
exampl~,
textbook
binary
skip
will
leads to simpler
to a buddy
a very
for
set of values
are competitive
balanced
to the
or by adding
of
is
structures
can reachieved
sizes
techniques
to
The
of elements
approach
the second is ideally
list
costs.
pair
behaviour
The first
allocation.
any
number
space for pointers,
the
increasing.
of askip
and delete
a small
some extra
constraint
insert
between
are
height.
exponentially
terms
that
height
using
on the notion
search,
is to insist
a given
byeither
the
based
logarithmic
It
Sedgewick*
the
stor-
@(lgz
extra
n)
stor-
368
MUNRO
age whether
we want
Finally
lists
we
in which
Although
are
new
done
skip
lists
of the previous
and if we become
we are able
to achieve
of the
the
red-black
2
The
2-3-4
A natural
starting
skip
of
some
skip
costs
list
least
at
these,
h +
list
list,
h
(h
>
1)
or
higher,
taken
call
Fig.
exist
this
1, there
1-2 skip
from
first
any
there
We
between
of the structure
between
skip
and
principles,
is simpler
than
the
the search
is the
list
in
most
number
the
Llg(n
case?
+ I)j
exist
pointers
Clearly,
pointers.
exactly
pointers
l~j
of (horizontal)
worst
n
In
pointers
at level
3, and,
level
1,
list
of Fig.
that
cause
will
may
cause
analogy,
of
grows,
and
old
of a single
all
nodes
in
the
at
example
pointers
of the
sum
is well-known
and
so we get
(including
elements
header,
that
the
of the
V2 (n + 1)
represent
never
A search
to throw
fact
example,
maximum
header)
1)+
is
the
at ion of n+l.
of pointers
manner
at level
[*J.
[3, pp.
in
3
from
shrink,
list
1,
numbers
exceeds
of n
an extra
that
after
line
in
the
list
skip
of code
2 horizontal
list.
steps
at
may
want
each
level
to
node
triple
the
of
we
will
case
+ 1)]
will
have
to be
n) time.
the
The
deletion
1(a),
10 to
Llg(n
[lg(n
+ l)j
is done
it
is done
may
of
will
5 for
cause
shrink
+ l)J
n) worst
list
way
of Fig.
cause
and
elements
have
case cost
worst
problem
17
may
to shrink,
as well.
case
will
pointer,
and
require
return
of each
this
update
above
node
set of horizontal
of our
a pointer
linked
space
as an array
the
version
in the
because
overhead
implement
the
of its
key
(or
the
key
1-2 skip
case.
We
simplicity.
of horizontal
of pointers,
each
pointer,
of the
worst
of
almost
structure;
is considered
set
can
by a right
to
list
worst
section,
pointers
This
data
be substituted
notion
@(lg2 n)
preceding
of pointers.
up to 6n pointers
to this
we may
the
list
the
in the
requirement
pointer
). Therefore,
will
of
encountered
as a linked
space
If the
able,
the
costs
be to implement
each
itself
same
advantage
1 requires
worst
a 1-2 skip
to
logarithmic
solution
a down
binary
number
in the
We
to take
will
h+
of
the
to
list
out
growth
in
up to ~(lg2
tree.
up
in a @(lg2
Achieving
would
list
is performed
this
and up to
thus
horizontal
2n.
probabilistic
in
1‘s
the maximum
2-3
1-2 skip
general,
to grow,
One
all n ~ 1,
of
Therefore,
in a 1-2 skip
as in the
for
and
In
case update
of pointers
a 1-2 skip
the
and
the
height
from
analogous
corresponding
in
when
a larger
costs
This
113–114]),
number
take
for
i.
including
is exactly
2n – v~(n+
where
pointers
of pointers,
is ~~~f”+l)j
(see, for
those
-1
number
may
as arrays
Therefore,
. . . . Llg(n
each
time.
then,
pointers
Since
of an element
completely
grow.
have
1,2,
nodes
space
h to
pointers.
an insertion
to
height
of @(h)
A deletion
3 to
from
all
the
since
constant
pointers,
node.
In
on implementing
allocate
copy
new
1
above
grow.
problem,
takes
of
to
to
the
of heights
resulting
1*J
have
into
node
change
a way
at most
we
node
have
to
of the
lists)
height
2 to 3, and
3 to 4.
insist
pointers
from
described
a great
if we
as linked
we
from
height
setting,
to height
15 in the
from
elements
is not
of horizontal
a node
the
+ l)J
to height
2 in a row,
grow
algorithm
element’s
our
than
to
in general,
an
in
sets
this
grow
13 to grow
of
rectified
of element
to grow
~lg(n
spot.
is easily
17 to grow
insertion
initially
configuration
elements
cause
cause
17 again
to
at
bring
from
by
of height
insertion
will
will
will
appropriate
3 elements
three
the
the
up
(rather
node,
of these
l(a)
2, that
in
*=
1)
This
example,
to height
of a
header
addition
at
at level 2, at most
pointers
the
1 in a row.
of these
the
exists
lists
invalid
in 3 elements
middle
is made
the
results
the
than
trigger
middle
However,
there
1 higher
that
h – 1.
we see from
that,
n elements
we require
of height
As
of
of height
list
the
For
looking
This
comparisons
1 in the
now
2-3 tree
requirement
a 1-2 skip
2. If this
In general,
the
of key
by letting
delete
examine
strict
1
balanced
and
therefore
node
n–(1+2+4+...
+2’–2
,-I
‘J=
[
Therefore,
the maximum
the
of height
raised,
[+1
the
3 elements
without
level.
+ 1)].
of height
of course,
skip
kth
least
in
insert
the
a skip
skip
list.
there
most
in
We feel
What
has
the
a bit
correspondence
view
skip
at
searches
time,
a (n+l)st
2 nodes
skip
2-3 trees.
1-2
every
in
may,
increase
of height
a 1-2
view.
height
We should
of the
a one-to-one
tree
h is of
of a perfectly
which
case number
an element
This
or through
idea
in
Although
that
1 or
list
than
a level,
at the same
to 2 Llg(n
insertion
adding
node”.
nodes
skip
the
one
logarithmic
a Oth and
either
is with
namely
of relaxing
kth
height
two
simpler
directly
An
storage,
down
ahead
worst
+ 1)]
point
k).
take
Assuming
the
implementations
with
the
3 [lg(n
3, etc.
at
fixed
consequences
exists
down
ex-
to drop
element
we let the
are prohibitive.
“every
manner.
simple
cavalier
implemented
the 3rd
point
list,
height
lists
their
a bit
skip
formalism.
balanced
(for
of
in a top-down
an implementation
trees
starting
node
versions
are essentially
versions,
are simpler,
that
are guaranteed
deterministic
updates
these
tensions
it or not.
present
ET AL.
unacceptpointers
if we choose
these
DETERMINISTIC
SKIP
LISTS
369
(a)
3
2
(
5
)(
12
)(
13
(b)
Figure
1: A 1-2 skip
list
and
corresponding
2-3 tree
II
II
II
1,
H
Figure
arrays
to have
exponentially
increasing
let’s
all nodes
For simplicity,
heights
2i, for some
of the nodes
will
will
be equal
skip
list
considered
array
variant
skip
list
in the
of Fig.
scheme
out
storage
the
for
exactly
ers at level
n
list.
will
that
be the
our
>
In
3.
n pointers
2, at most
skip
2
list
list
addition
to
122J
the
pointers
in general,
at most
2i
2’ (Ml
-1)
p0intersat1eve1s2i+12
*
floors
1
and
Jf0ra11n~3
we define
2i–21
def
=
an
we get the
forn>3
E
i=O
o
{
hard
forn=l,2
upper
(%+
ex-
point-
at levels
‘1
i+1
the
II
bound
-1)1 +1
‘-(1+2$+2
[
is exactly
[lg(Llg(n+l)j-l)j
2.
2~—1
and 4, and,
2*
if we remove
increase
there
1~~
and
of pointers
-l)]
z
i=o
the just
is not
these,
1, at most
the
15 into
2LW lk(~+l)~
number
Llg(Llg(n+l)j
this
in Fig.
list
maximum
n+l+
for
does not
It
the
1-2
reserve
list
of 1-2 skip
fore,
and
in the
under
much.
at most
at level
heights,
skip
one shown
by very
has
heights
We
1-2
new skip
header
logical
If we insert
the resulting
heights.
physical
nodes
section.
implementation
have
physical
of the
of the
requirements
to see that
pointers,
l(a),
their
last
skip
physical
will
. . .. The
heights
of deterministic
It turns
ist
exceed
to the
implementation
described
the
i = 0,1,2,3,
never
they
term
say that
2: Array
Ther~
for
3
the
l)n
maximum
implementation
defining
since
+ %
an
it
hss
wehavecw
1,
+
number
of
of a 1-2 skip
can
be
only
=
a31=..
. awo
Hence,
we never
list
computed
a few
... =
=
for
1.25,
allocate
pointers
=
and
more
in
the
of n elements.
fast
terms
ff6
all n ~ 1
to
which
.5,
grow
I-Y7 =
2.282n
array
sum
accuracy,
a high
cr~ cx 1.281
than
The
very
‘“”cY30
for
n ~
pointers.
fast;
=
1,
511.
MUNRO
370
When,
we use
the
not,
a new
and
out
an
level
node
At
old
this
Consider
When
heights
by
1, only
copied
increase
allow
their
required
the
for
achieving
an element,
the
array
in
order
have
to
to
list
in
Berkeley-based
less than
buddy
system.
size
equal
In
C
under
of Unix
in
the
It is therefore
physical
will
node
power
memory
manager.
and
if we also store
node
in the
of physical
pointer
node
heights
itself,
the
example,
the
logical
then
for
of
height
for
place,
to
our
set
grow,
we
larger
and
of free
the
we
nodes
final
memory
record
the
that
to grow
to height
that
has to grow
node
manager
will
grow,
will
grow
make
only
one
call
of height
the freed
element
i, etc.
i+j,
can also
heights
We
between
out
of height
the
first
h.
to
the highest
i and
that
lowest
exactly
memory
we may
if,
from
of height
that
next
to height
to the
so,
haa to grow
element
the
do
drop
element
we find
since
can
we
first,
Then,
can
manager
elements’
is of height
i+ j.
that
to height
the
whether
which
Suppose
element
storage
raise
bottom-up.
we
determine
4
Top-down
1-2-3
correspondence
be easily
memory
of
a number
it has
element
i.
Thus,
manager
we
for
subsequently
an
reuse
i for the new element
to grow
[~1,
-. .,m–2,
Fig.
3 shows
skip
list,
that
2-3 trees
For
a deterministic
(’Y1 -1,
will
in
[4],
list
nodes
a 2-3-4
tree
call
1-2-3
and
1-2 skip
B-tree
skip
m-l
we
any
lists
of order
that
of the
m,
will
allow
same
height
and its corresponding
skip
list
for
obvious
reasons.
the
by
l-word
of each
define
between
in a row.
for the
that
can
lists
generalized.
4
structure
allocated
we
skip
of
by
skip
nodes
i = 2, 3, . . . (assuming
that
long).
to
the
can
if we have
we should
of
choose
= 4 bytes
height,
to the
second
The
to be such
space
takes
1 from
set
the
or after
memory
our
to
h – 1 before
a (binary)
adequate
to tune
heights
into
2i – 3, for
is 1 word
by
our
by
lg n) free
into,
most
4.3 BSD),
purposes)
For
then
of 2 (reduced
convenient
exactly
can
programming
allocated
allocation
element
fit
We
ourselves
a request
smallest
h to level
array
routine),
manager,
O(lg
size
except
now
than
search,
second,
in-
size
call
choose
rather
the
and
In
if we
our
which
leaves
sidestep
situation.
and
implementation
Unix.
(e.g.
are
particular,
the
level
any
each
implemen-
have
one
a
may
version,
can
storage
of size
node
In
cost.
We
elements
This
@(lg lg n) calls
element
in the
single
top-down,
be a separate
of us find
bytes
results
to
by choosing
each
in
512
entire
keys,
many
of
A
be avoided
during
one.
improves
ation
an insertion
node
as
naive
n).
array
structure,
When
a new
it
O(lg
its naive
our
to the
if some
node
the
The
we
and
old
one
rectifies
invoked.
is serendipitous
which
with
key in that
search
the
than
the
a free
request
requested.
of a skip
place
likely
the
the array
used for administrative
request.
list
that
the
nodes,
release
size.
its
case update
that
with
request
and
to
somewhat.
calls
along
in the
in the
height
for
initially
repeatedly
node
but
of code
proper
to
one of each
list,
course,
hand,
more
nodes,
imple-
levels,
the
a search
when
versions
blocks
other
@(lg lg n)
keeping,
update
list
Of
piece
at the
will
observe
programming
modest
the
similar
overhead
1-2 skip
namely
the
This
a skip
+ l)J
to change
to initiate
now
environment
bytes
On
node.
a time
We may
bytes
this
(admittedly,
adding
of the
Llg(n
we can splice
new
procedure
lower
of the
of free
list
noting
simply
pointers.
linked
pointers.
all
in order
we have
or
a few
include
routines.
so that
In the
worth
than
implement
pointers
@(lg n) worst
most
logarithmic
6n
is also
array
a buddy
is tuned
2,
cost
the
be done
in
space
Section
that
can
that
more
the
more
the
simply
update
environment,
up to 15%
point
list
implementation
in
of
we
is
case
is,
implementa-
uses
worst
be streamlined
be wondering
list
which
raise
for
will
ation,
the
to
do that
/delete
implement
sert
linked
described
n)
at this
1-2 skip
require
can
sum
1-2 skip
doesn’t
achieving
It
technique,
also achieves
but
change
coder
node,
which
is code simplicity.
have
node,
of the
costs,
reasonable
insert
of the
it
require
It
array
t ation
time
as well.
we might
emphasize
of our
if the
@(lg2
also
to
ation
environment.
non-buddy
heights
case
like
counterpart
the
be
that
same
any
described,
to
the
would
implement
environment,
merely
to the
worst
pointers,
advantages
has
will
copied,
cost
implementation
2.282n
update
ment ation,
may
n)
in
2i+l.
physical
the
in
new
heights
Hence,
be
logarithmic
list,
answer
will
case ~(lg
1-2 skip
case
we only
their
array
insertion
2i+1
time.
we apply
a worst
are the
The
and
We
If
be increased
nodes
that
achieved
of the
worst
height
is proportional
uses only
what
heights,
the
height
to
the remaining
nodes
pointers
to
of logical
have
of logical
node;
all
are of physical
of them
grow,
exists.
@(lg n)
1) nodes
an insertion,
thus
with
tion
>
of the
Having
list
node
logical
To delete
costs
(i
of them
to
one
and
the
to do so in constant
heights
which
2i
has
if
to be copied
achieve
of all
a new
them
have
we
All
the
into
field,
to be created,
the
2i+l.
a node
pointer
node
point,
2i + 1,...,
the
insertion,
has
of the
node.
cost.
doing
higher
ET AL.
As
be
noted
performed
maintain
approach,
splitting
insertions
top-down,
a stack
with
we insert
the
search
an element
any
gap
of size 3 into
searching
for
the
element
this
that
way
the
in
eliminating
structure
a
path.
in
two
the
tree
the
skip
of size
can
need
Adopting
a 1-2-3
gaps
to be inserted.
retains
2-3-4
thus
to
this
list
We ensure
gap
by
1, when
invariant
in
DETERMINISTIC
SKIP
371
LISTS
(a)
(b)
Figure
-
3: A 1-2-3
skip
—
and
corresponding
2-3-4
-
0- -
HEADER
0- -
9
+ *
+
—
+
—
o- *
/20
13
Figure
●
Ill
0- -
o- +
30
4: Top-down
0- -
~
39
1-2-3
b
●
~
skip
0- +
o- --+
c- +
HEADER
9
or
without
1 higher
the
than
gap
below
When
with
we are going
2, the
1-2-3
skip
list
to level
raise
of
we look
2 of the
39, then
new
node
skip
list
of height
is shown
level,
When
we look
that
we drop
we simply
list
with
a new
allowed
only
leaves
gaps
us
3(a).
the
case of inserting
We
2 and
start
we raise
we move
to level
1 having
4.
to
at
level
the
key
20 in
3 of
the
48, then we drop
level
2 of
1 of 13, and
20.
resulting
a
header
of height
exist
at least
in the
the
first
that
or
ith
(i +
gap.
l)st
to the
of height
we find
h —
the
If there
is only
then
gap
then
and
going
(for
the
if there
gap,
to
some
we also
the
list.
there
1 in the second
one node
we lower
and
we lower
of us,
(i + l)st
and
that
at the
of the skip
first
If we are not
to drop,
merging
from
search
height
h – 1 there,
of them.
gap,
our
in the
for
— size as
either
an element
down
we work
search
the side-effect
by
we see ahead
2 nodes
gap,
of the
the
h that
list,
the
minimal
we start
h equal
of height
first
above
is handled
precisely,
skip
want
to have
borrowing
we are going
in
— but
This
to drop
1 node
node
We
be removed
it.
at level
a 1-2-3
as well.
will
More
and
60
from
manner
If we are going
gap
53
an element
that
neighbour.
o- +11
deletion
a neighbour,
we raise
13, we
we insert
The
Ill
s- +
+
51
through
is only
list.
0-
each gap is of legal
we pass
a level.
insert
element
that
level
element
in Fig.
skip
the
inserted
header,
1-2-3
we find
in a row,
down
39
To delete
at the
height
●
-
0- -
48
in a top-down
algorithm
consider
we drop
list.
0- +
41
more
our
at level
60
Ill
●
at level
be
and
newly
skip
Fig.
skip
of the same
after
1. Since
1 and
To
header,
to drop,
the bottom
of height
a valid
one;
As an example,
the
of the
30
+11
insertion
0-0- -
5: Top-down
element.
at the
if we see 3 nodes
we reach
header,
search
height
the middle
of sizes
inserted
our
the
that
and
we raise
node
the
we start
0-
55
-
o- +
20
13
Figure
precise,
53
0- +
●
●
●
d
-
-
6 +
51
list
{1,
●
0- +
—
with
tree
●
—
b ●
—
b ●
●
-
list
keep
drop
i ~
1)
track
of height
h – 1
separator
node
372
MUNRO
ET AL.
tail
head
bottom
Figure
of the
ith
nodes
of height
h – 1 in the
We then
drop
them.
way,
and
until
we remove
didn’t
allow
1-2-3
its
any
of 53, and
top-down
linked
pass
through
linked
To
avoid
their
of
from
1
tree
is
Both
structure,
implementation
lists
ation
using
algorithms;
node
single
and
by
of the
having
while
as in
[4].
node
and
two
also
the
Admittedly,
pull
the
comparisons
back
are actually
this
one might
keys
to
moves
view
made
list
are
we
the
data
node
type
{int
of
These
(see Fig.
6
a binary
node
functions
unsuccessful.
*cl; }
==
= x–>r;
x–>key)
list
return
Observe
for
for
a pointer
or a pointer
in each
procedure
?
x
: bottom
) ;
that
node,
equality
the
and
a binary
first
at the
tree.
lowest
containing
if the
search
version
it is identical
search
only
to the node
to bottom
to the
The
was
uses 3-waY
search
second
version
and
it is skip
level,
in flavour.
If we choose
then
code;
*r,
x
bottom)
(v
key sought,
tests
nodes
definition
key;
==
}
the
is just
struct
x->r;
}
branches
nodes
tree.
Assuming
:
{
> x->key)
(x->d
return(
code,
and
! = bottom)
(v
X = x–>d;
on the
the
(x
than
us to a representation
as a skip
x->d
= head;
if
a level
into
?
x;
while
cases
sentinel
avoid
*
trees
algorithms
our
< x->key)
;
Seaxch(v)
node
x
simpler
in
(v
{
on
rotations
cases
Furthermore,
and
what
special
head
tail.
we
*
for
numerous
double
! = x–>key)
v;
done
red-black
such
because
the
as
}
or as
of top-down
is much
pointer,
v can be written
of these
is
just
=
x
of pointers
work
d is a down
= v;
(v
return(x)
to level
counterparts
the
value
key
= head-
55 from
the
in which
between
tree
nodes.
and
for
x;
x
can be implemented
than
as skip
a dummy
indirection,
*
bottom->~ey
right.
and
7).
list
involving
the
duce
node
we are left
resulting
or arrays
pointer
Search(v)
1, is a valid
continue
The
list
algorithm
3 of the header,
then
list
all
the
complicated
and
intro
list
implement
balanced
notoriously
bottom
55.
skip
represented
arise
We
of pointers
because
corresponding
that
{
*
skip
v;
of height
2 of 53, then
lists
2-3-4
left
39.
1-2-3
the
trees
at level
to level
are simpler
list
down
and other
raise
remove
Moreover,
the
is not
in a
1-2-3
to search
node
in this
case of deleting
sizes for the skip
skip
empty
r is a right
int
implementations
one
1, what
where
function
int
our
of height
of
5.
of exponential
1-2
the
4. We start
we finally
either
the
Since
2
last
we remove
its neighbour
to be of size
J8 and
in Fig.
The
where
key to be deleted
of the mode
48, we move
2 of
using
level,
it with
consider
of Fig.
we lower
shown
at least
the
the
while
As an example,
and
exist
we raise
for
list.
the structure
level
representation
h – 1. We continue
neighbour).
gaps
list
if there
gap,
bottom
1 (if the
the removal
skip
and
ith
to level
1, we swap
1, and
after
gaps,
the
of height
of height
with
l)st
we reach
the node
node
(i+
6: Linked
code
a matter
we simply
whenever
the
to
second
version
insert
a key
of filling
in
have
necessary,
to add
for
v into
a few
a node
the
search
a 1-2-3
gaps
in
code,
skip
list
the
above
in a horizontal
link
DETERMINISTIC
SKIP
373
LISTS
‘
.-
‘~
‘a
header-
maz
+1
‘
40 I
~
ma
+
.
1r
,,
~ 30
20
‘
“ 50
40
I
1
v
bottom
~
+
I
Figure
7: A 1-2-3
skip
list
and
its
corresponding
int
Insert(v)
This
int
v;
the
linked
function
skip
node
*t,
We
*x;
x = head;
bottom->key
while
(x
while
if
(v
= v;
!=
bottom)
> x->key)
((x->d
x = x->r;
==
bottom)
==
bottom)
&&
(v
x->key))
II
(x->key
=
==
x->d->r->r->r->key))
= x–>r;
t->key
t->d
= x->key;
= x->d->r->r;
x->key
{
x->r
=
!=
tail)
t->d
= head;
= t;
t->r
= tail;
t->key
= maxkey;
emphasize
and
here
rough
inserted
in
list
code
published
trees.
and
an implementation
counts
the
simplify
trivial
extension
is much
of the
number
studying
shorter
strategy
can
maintain
of skipped
ofwhen
of
tradeoffs
basic
one
nodes
and
but
also
lists.
We
tosplit
tohigher-order
such
our
that
are several
example,
thetest
that
implementations
There
For
again
Ccodeistoshow
working
other
outlined.
also
that,
tree
algorithms,
list
into
skip
implementation
tradeoffs
in
code.
as discussed
such
simplified
in
[4],
other
as AVL
standard
trees,
implementations
can
be
througha
representation.
Similarly,
{
node));
to
balanced
only
transformed
(node*)malloc(slzeof(struct
head
}
return(i);
}
Note
balanced
skip
t
for
v was
in theskip
detail.
= x->d->r->key;
}
X = x->d;
(head->r
that
are currently
= t;
than
we have
allow
node));
value
was already
the above
debugged
for
not
1 if kev.
Oifv
like
developing
thus
(node*)malloc(sizeof(struct
t->r
simpler
a field
((x->d
t
fully
and
that
return(0);
if
this
in
==
representation
re-inserted.
ofgiving
insertion
{
and
would
purpose
list
returns
list,
it was not
{
}
if
1
v
1
T
Despite
the
deletion
the
fact
that
insertion
code,
it is an even
difficulty
than
is the
case for
algorithm
is
it is a bit
greater
quite
longer
reduction
insertion.
easy
than
to
the
in coding
374
MUNRO
5
Conclusion
We
have
skip
lists,
rithmic
simple
3)
that
search
in
any
leaf
the
height
cal
steps
in
the
skip
list.
and
hence
tree
in which
is the
the
several
Fig.
dant
times
of
list
searching
the
other
The
respectively.
The
both
of them
than
the
the
Note
search
tree
the
a linked
one.
(AVL,
2.282n
and
in the
ations
in
One
might
think
more
is
the
not
in
lg n).
require
skip
list
“skip
down
2-3-4
trees,
a systematic
way
1for
better
in
advanced
trees
[6] that
should
plementations
tures,
and
space
case
the
worst
this
unlike
are
not
schemes
require
the
linked
lists
in the
worst
case.
asymptotic
pointers
case
than
though,
our
ex-
on average,
(when
deterministic
balanced
for
casual
implementation
on the
of binary
such
to
of
trees
trees,
Moreover,
top-
it provides
pointers
based
that
on
substantially
are
balanced
simpler
of algorithms
on such
development
can
of stan-
as 2-3
“cross”
words
average.
implementations
trees.
lead
6 .58n
of new
imstruc-
methods.
References
[1] G. M. Adel’son-Vel’skii
rithm
for
the
Akademia
they
are
search
skip
trees.
implementations
lists
This
and
Organization
Nauk
E. M.
Landis.
“An
of Information”.
algo-
Dolclady
SSSR, vol. 146, 1962, pp. 263–266.
glish translation
in Soviet
Mathematics
Doklady,
En-
vol. 3,
pp. 1259–1263.
and E. McCreight.
“Organization
tenance of Large Ordered
vol. 1, 1972, pp. 173–189.
[3] R. L. Graham,
[4] L.
Guibas
work
for
ciet y. Ann
[5] H.
and
Addisontrees”.
Arbor,
[6] K. Mehlhorn.
Michigan,
and
“A
Ott.
dichromatic
Harper
1991.
Structures
frame-
Symposium
Computer
in
So-
1978, pp. 8–21.
Data
Data
Con-
1989.
L. Denenberg.
Collins,
h~orrnatica,
O. Pataahnik.
lgth Annual
Science IEEE
of Computer
Algorithms.
and
and Main-
Acts
Wesley,
R. Sedgewick.
balanced
R. Lewis
their
Indexes”.
D. E. Knuth
crete Mathematics.
Foundations
that
about
list
structures
to the
in
implementation
list
words
the
of a number
perhaps
1-2
stored
are
AVL
data
are not
array
4.56n
of the
list
6.26n
to view
take
if heights
structures
and
will
is less
and red-
the linked
simpler
data
used
by the AVL
representation
substantially
of our skip
case, which
list
5, 8
(4.54n
linked
about
2 to
of heights
on the average}
1-2 skip
the
list”
abstract
balanced
etc.),
the
1.582n
and
dard
our
to
5.49n
words
of the
On
+ @(l)
minimize
other
and
minimizing
require
at level
case,
6n pointers
lists,
cost,
n lg n pointers
capped
1-2-3
about
list
average,
list
search
structures,
like
of our
worst
require
skip
search
the
ation
the
node,
words
of comparisons
red-black,
implementations
pointers
Probabilistic
pected
implement
the
skip
in nodes)
[2] R. Bayer
array
implement
1-2-3
The
history-independent.
The
of the
in the
of heights
if heights
average,
The
1, 4 more
implementation
(4.74n
on the
node
skip
array
lists
case.
implementation
probabilistic
the
worst
of the elements
taken
8n
skip
even if we assume
in the worst
always
5 .77n
lead
size of the
31gn
to
data
and
words
framework
of comparisons
(tuned
nodes)
on
node
The
about
stored
elements
words
on average,
the
of height
&
take
of our
of each
the array
6.25n
of the space
list
not
produc-
1.2 Ig n + (3(1),
our
cousins,
schemes
have
by
and
number
list
that
of
redun-
also
comparisons
expected
though,
probabilistic
example
to the
number
skip
value
in a general
+ @(l)
be about
1.9 lg n + ~(l)
probabilistic
value).
their
of
expected
to
skip
setting.
is 21gn
seem
for
These
shrink)
rotation
number
list
search
height
elements
~ of the
Hence,
trees.
words
the
tree
black
the
8 words.
always
lists,
for
2 pointers
to allocate
in
skip
of 2
bytes
1 key,
will
Most
powers
these
implementation
for the at most
take
4/5
be
a multiway
in the
proportional
list
value
will
4 of
trees
pointers
each.
only
we have
of our
for
at most
words
may
same
and
(or
dis-
the
of allowing
grow
skip
case
skip
a key
node
pointers,
splitting
operation
to
in the
worst
1-2-3
extra
nodes)
time
have
25).
structure,
a standard
require
subtree
2 and
easier
than
23 in
with
in which
hand,
would
entire
the
pointers
obvious
A
the
6 to 13, etc.
One
our
for
indeed
multiway
a much
nodes
and
node,
8n
4 words
long
keep
for
For simplicity,
So, to store
list
at most
Consider,
Unix.
allocate
red-black
we also store
more
lists
encounter
comparisons
two
of horizontal
tree
may
two
and
point,
per
implementation
take
for
distinctions
of pointers.
(e.g.
a representation
becomes
list
pointers;
lists
of threading
(or merging
in
skip
comparisons,
advantage
ing
Pugh’s
in a skip
1 involves
will
that
take
array
that
from
2) bits
program.
1 word
they
purposes.
linked
will
are
and
The
skip
child.
1 (or
us
systems
bytes,
words.
node
right
of
and
same
as a probabilistic
keys
AVL
of the
representational
number
as linked
an element
away
tree,
search
the
Thus,
level
ease of manipulation.
is that
search
flagged)
list
in
and
of
in C under
Unix-based
administrative
in the
same
skip
moved
on several
a varying
implemented
the
to
element
as a binary
right,
the
to
of verti-
of any
a multiway
to the
root
number
search
[4],
the
that
Berkeley
number
corresponds
the
aa a (possibly
have
the
length
to
1
a multiway
from
be viewed
or in
introduced
impact
tinction
in
can
tree,
focused
or
the
noted
list,
w
length
path
list,
an element
we
we have
this
viewed
(Fig.
many
programming
assume
loga-
observed
environments
example,
deterministic
guaranteed
We
be
path
for
be viewed
structure,
can
of
with
costs.
the
path
As
Pugh
and
list
skip
a skip
can
structures
same;
of the
versions
update
which
multiway
While
that
and
a skip
tree
of the
several
data
search
and
list,
in
introduced
ET AL.
Structures
and Algorithms,
and
vol.
1.
DETERMINISTIC
SKIP
Springer-Verlag,
[7] T.
1984.
Papadakis,
Search
and
375
LISTS
J, I. Munro
Update
Costs
and
in
P. Poblete.
Skip
Lists”.
“Average
BIT,
to
appear.
[8] W.
Pugh.
Balanced
“Skip
Trees”.
Lists:
A Probabilistic
Communications
no. 6, June 1990, pp. 668–676.
Alternative
to
of the A CM, vol. 33,