Quad Trees
Region data vs. point data.
Roads and rivers in a country/state.
Which rivers flow through Florida?
Which roads cross a river?
Network firewalls.
(source prefix, destination prefix, action)
(01*, 110*, drop packet)
27
dest 24
8
source
15

R-Trees
Extension of B+-trees.
Collection of d-dimensional rectangles.
A point in d-dimensions is a trivial rectangle.
Non-rectangular Data
Non-rectangular data may be represented by
minimum bounding rectangles (MBRs).
Operations
Insert
Delete
Find

BSP Trees
Binary space partitioning trees.
Used to store a collection of objects in ndimensional space.
Tree recursively divides n-dimensional
space using (n-1)-dimensional hyperplanes.
Space Partitioning
n-dimensional space
splitting hyperplane
(n-1)-

Multidimensional Range Search
Static collection of records.
No inserts, deletes, changes.
Only queries.
Each record has k key fields.
Multidimensional query.
Given k ranges [li, ui], 1 <= i <= k.
Report all records in collection such that
li <= ki

Internet Routers
http:/www.windowsecurity.com/whitepapers/Excerpts_from_The_Encyclopedia_of_Networking_.html
Sample Routers
Router Functionality
I
N
P
U
T
P
O
R
T
S
O
U
T
P
U
T
P
O
R
T
S
Rule Table
Used to decide where to send a packet next
(next hop).

Binary Tries (continued)
split(k).
Similar to split algorithm for unbalanced binary
search trees.
Construct S and B on way down the trie.
Follow with a backward cleanup pass over the
constructed S and B.
Forward Pass
Suppose you are at node x, which

Bottom-Up Splay TreesAnalysis
Actual and amortized complexity of join is
O(1).
Amortized complexity of search, insert, delete,
and split is O(log n).
Actual complexity of each splay tree operation
is the same as that of the associated splay.
Sufficien

B+-Trees
Same structure as B-trees.
Dictionary pairs are in leaves only. Leaves form a
doubly-linked list.
Remaining nodes have following structure:
j a0 k1 a1 k2 a2 kj aj
j = number of keys in node.
ai is a pointer to a subtree.
ki <= smallest key

B-Trees (continued)
Analysis of worst-case and average number
of disk accesses for an insert.
Delete and analysis.
Structure for B-tree node
Worst-Case Disk Accesses
7 12
4
1 3
9
5 6
Insert 14.
Insert 2.
Insert 18.
8
15 20
10
13
16 17 30 40
Worst-Case

Splay Trees
Binary search trees.
Search, insert, delete, and split have amortized
complexity O(log n) & actual complexity O(n).
Actual and amortized complexity of join is O(1).
Priority queue and double-ended priority queue
versions outperform heaps,

B-Trees
Large degree B-trees used to represent very large
dictionaries that reside on disk.
Smaller degree B-trees used for internal-memory
dictionaries to overcome cache-miss penalties.
AVL Trees
n = 230 = 109 (approx).
30 <= height <= 43.
When the

Red Black Trees
Colored Nodes Definition
Binary search tree.
Each node is colored red or black.
Root and all external nodes are black.
No root-to-external-node path has two
consecutive red nodes.
All root-to-external-node paths have the
same number o

Red-Black TreesAgain
rank(x) = # black pointers on path from x to an
external node.
Same as #black nodes (excluding x) from x to an
external node.
rank(external node) = 0.
An Example
10
2
1
1
0
1
2
7
40
1
3
1
0 0
3
1
5
0
0
1
2 30
8
1
20
0
1
0
0
25
45
1

Dictionaries
Collection of items.
Each item is a pair.
(key, element)
Pairs have different keys.
Application
Collection of student records in this class.
(key, element) = (student name, linear list of
assignment and exam scores)
All keys are distin

Static Dictionaries
Collection of items.
Each item is a pair.
(key, element)
Pairs have different keys.
Operations are:
initialize/create
get (search)
Hashing
Perfect hashing (no collisions).
Minimal perfect hashing (space = n).
CHD algorithm.
O(n)

Leftist Trees
Linked binary tree.
Can do everything a heap can do and in the
same asymptotic complexity.
insert
remove min (or max)
initialize
Can meld two leftist tree priority queues in
O(log n) time.
Extended Binary Trees
Start with any binary tree

Interval Heaps
Complete binary tree.
Each node (except possibly last one) has 2 elements.
Last node has 1 or 2 elements.
Let a and b be the elements in a node P, a <= b.
[a, b] is the interval represented by P.
The interval represented by a node that has

Improve Run Generation
Overlap input,output, and internal CPU work.
Reduce the number of runs (equivalently, increase
average run length).
DISK
MEMORY
DISK
Internal Quick Sort
6 2 8 5 11 10 4 1 9 7 3
Use 6 as the pivot (median of 3).
Input first, middle

Tournament Trees
Winner trees.
Loser Trees.
Winner Tree Definition
Complete binary tree with n external
nodes and n 1 internal nodes.
External nodes represent tournament
players.
Each internal node represents a match
played between its two children;
the w

Double-Ended Priority Queues
Primary operations
Insert
Remove Max
Remove Min
Note that a single-ended priority queue
supports just one of the above remove
operations.
General Methods
Dual min and max single-ended priority
queues.
Correspondence bas

Improve Run Merging
Reduce number of merge passes.
Use higher order merge.
Number of passes
= ceil(logk(number of initial runs)
where k is the merge order.
More generally, a higher-order merge
reduces the cost of the optimal merge tree.
Improve Run Me

Advanced Data Structures
Sartaj Sahni
Clip Art Sources
www.barrysclipart.com
www.livinggraphics.com
www.rad.kumc.edu
www.livinggraphics.com
What The Course Is About
Study data structures for:
External sorting
Single and double ended priority queues
Di

Advanced Data Structures (COP5536)
Exam 3, Sample 3
Note. All answers will be graded on correctness, efficiency, clarity, elegance and other normal criteria that
determine quality. The points assigned to each question are provided in parentheses.
1. For S