Data Structures in Java
Session 14 Instructor: Bert Huang http://www1.cs.columbia.edu/~bert/courses/3134
Data Structures in Java Session 14 Instructor: Bert Huang - - PowerPoint PPT Presentation
Data Structures in Java Session 14 Instructor: Bert Huang http://www1.cs.columbia.edu/~bert/courses/3134 Announcements Homework 3 Programming due Homework 4 on website Review Lists, Stacks, Queues Trees, Binary Search Trees
Session 14 Instructor: Bert Huang http://www1.cs.columbia.edu/~bert/courses/3134
findMin, findMax, insert/delete, search
findMin (or max), insert/delete, no search
insert/delete, search
Stores complete order information
Stores incomplete order information
Stores no order information
1 2 3 4 5 6 ... K-3 K-2 K-1 K
array position
1 2 3 4 5 6 ... K-3 K-2 K-1 K 1 ... N-2 N-1
function
evenly in the array
the same array index
h(7) = 2, h(12) = 2
collisions are inevitable
for x, delete
λ λ λ λ λ/2
for i = 1 until an empty slot is found
7 7 12 7 12 2
end of that cluster
value will collide with the cluster, and (b) collisions in the cluster get more expensive
x x x x x
searching.
even if table isnʼt full!
guaranteed to find empty slot
λ ≤ 1 2
9 9 16 9 16 2
key
f(i) = i × h2(x) h1(x)
9 9 16 9 2 16
memory
donʼt get collisions