6.851: Advanced Data Structures
Spring 2010
Lecture 1 — 2 February, 2010
Prof. Erik Demaine
Scribe: Kevin Kelley
1 Administrivia
Homework is subject to a onepagein, onepageout rule; that is, assignments will be kept to one
page, but you may only turn in a single page in response. Your single page must be typeset with
L
A
T
E
X. A template is available on the course website.
2 Overview
Today’s topic is the question of dynamic optimality; that is, of whether there is a single “best”
binary search tree. (A more rigorous deﬁnition of “best” follows.)
3 Binary search trees
The binary search tree is typically viewed as a comparison data structure: smaller things are placed
to the left, and larger things are placed to the right. However, the binary search tree can also be
treated as a model of computation.
This model deﬁnes several unitcost operations. From a given position in the tree, it takes
O
(1)
time to walk to either the left or right child, to walk to the parent, or to rotate a node and its
parent. (Rotation is a simple tree operation in which a node
x
takes the place of its parent
y
, with
y
becoming a child of
x
. The two subtrees of
x
and the other subtree of
y
are redistributed such
that the structure of the binary search tree is preserved.)
3.1 Types of binary search trees
There are many types of data structures which meet these criteria. (All except tango trees provide
O
(lg
n
) lookups, insertions, and deletions.)
•
Simple binary search trees
– The na¨
ıve implementation.
•
AVL trees
– The ﬁrst selfbalancing tree.
•
Red/black trees
– A selfbalancing alternative to the AVL tree which provides the same asymp
totic bound but can be faster for workloads heavy in insertions and deletions.
•
Treaps
– A hybrid between a binary search tree and a heap (hence the name). Similar to a
randomized binary search tree. Provides amortized guarantees.
1
This preview has intentionally blurred sections. Sign up to view the full version.
View Full Document•
Weightbalanced trees
– Similar to a treap, but constructed to that frequentlyaccessed ele
ments are towards the root.
•
Splay trees
– Uses a particular method of moving accessed elements to the root of the tree in
order to provide fast lookups for recentlyaccessed keys.
•
Tango trees
– To be covered next lecture.
3.2 Beating
O
(lg
n
)
The
O
(lg
n
) limit may seem like a strict lower bound. After all, if we have a set of
n
elements,
we need lg
n
bits of information to uniquely identify each, and each pairwise comparison gives us
a single bit. However, some data structures, such as tango trees, manage to do so. We will revisit
this topic next lecture.
This is the end of the preview.
Sign up
to
access the rest of the document.
 Fall '10
 ErikDemaine
 Data Structures, LG, Splay tree

Click to edit the document details