kdTrees Continued
Generalized, incremental NN, range searching, kdtree variants
kdtree Variants
How do you pick the cutting dimension?
kdtrees cycle through them, but may be better to pick a different dimension e.g. Suppose your 3ddata points all hav
Skip Lists
CMSC 420
Linked Lists Benefits & Drawbacks
Benefits:
Easy to insert & delete in O(1) time Don't need to estimate total memory needed
Drawbacks:
Hard to search in less than O(n) time (binary search doesn't work, eg.) Hard to jump to the middle
S
Minimum Spanning
Trees
CMSC 420: Lecture 11
Following Dave Mounts
lecture in his lecture notes.
Skew Heaps
Selfadjusting version of leftist heaps
Difference:
Dont store npl (or any other auxiliary information at
the nodes)
always swap the left & right su
BTrees
CMSC 420: Lecture 9
Another way to achieve "balance"
Height of a perfect binary tree of n nodes is O(log n). Idea: Force the tree to be perfect.
Problem: can't have an arbitrary # of nodes. Perfect binary trees only have 2h1 nodes
So: relax t
Leftist Heaps
CMSC 420: Lecture 10
Priority Queue ADT
Efficiently support the following operations on a set of keys:
findmin: return the smallest key deletemin: return the smallest key & delete it insert: add a new key to the set delete: delete an arbit
Splay Trees
CMSC 420: Lecture 8
AVL Trees
Nice Features:
Worst case O(log n) performance guarantee Fairly simple to implement
Problem though:
Have to maintain extra balance factor storage at each node.
Splay trees (Sleator & Tarjan, 1985)

remove extra s
Balanced Trees
CMSC 420: Lecture 7
Balance
left height(u) = 0 if LEFT(u) = NULL 1 + height(LEFT(u) otherwise
left_height(u)
u
right_height defined analogously
height(LEFT(u)
balance(u) := right_height(u)  left_height(u)
Positive when right subtree is tal
Binary Search Trees
CMSC 420: Lecture 6
Binary Tree Traversals
B
A
C
D
E
F
G
H
I
J void traverse(BinNode *T) cfw_ if(T != NULL) cfw_ PREORDER(T); traverse(T>left(); INORDER(T); traverse(T>right(); POSTORDER(T);
inorder: HDIBEAJFCG preorder: ABEHIECFJG
Trees
CMSC 420: Lecture 5
Hierarchies
Many ways to represent treelike information:
A B D E F C G
linked hierarchy
I. A 1. B a. D i. E b. F 2. C a. G
outlines, indentations
A E D G C F B
(E):D), F):B, (G):C):A nested, labeled parenthesis nested sets
Defin
Lists, Queues, Stacks, Deques
Lecture 2: CMSC 420
General List ADT
The simplest (and often most useful) data structure is a
linear list: only care about linear ordering of items.
Supports the following operations:
get(L, i) return the ith item in L inse
What you should know about C+
Lecture 1.5: CMSC 420
C+
Almost every C program is a C+ program. That was an explicit goal of the design of C+. Why are we covering C+?
Important language, nearly the lingua franca of computer science. Languages like Python,
Problem Set #1: Basic Data Structures
Handed out on Feb. 12, due on Feb. 26 at the beginning of class. Remember: write your own
answers and use English or pseudocode when algorithms are requested. Late homeworks will not
be accepted (turn in whatever you
Problem Set #2: Balanced Trees
Handed out on Feb. 26, due on Mar 4, at the beginning of class. Remember: write your own
answers and use English or pseudocode when algorithms are requested. Late homeworks will not
be accepted (turn in whatever you have).
P
Problem Set #3: Heaps, Sorting, and MST
Handed out on Tues, Mar 4, due on Tues, Mar 11 at the beginning of class. Remember: write your
own answers and use English or pseudocode when algorithms are requested. Late homeworks will
not be accepted (turn in wh