
Lecture 5: Linear Sorting
Review
• Comparison search lower bound: any decision tree with n nodes has height ≥ dlg(n+1)e−1
• Can do faster using random access indexing: an operation with linear branching factor!
• Direct access array is fast, but may use a lot of space (Θ(u))
• Solve space problem by mapping (hashing) key space u down to m = Θ(n)
• Hash tables give expected O(1) time operations, amortized if dynamic
• Expectation input-independent: choose hash function randomly from universal hash family
• Data structure overview!
• Last time we achieved faster find. Can we also achieve faster sort?
Data Structure
Operations O(·)
Container Static Dynamic Order
build(X) find(k) insert(x)
delete(k)
find min()
find max()
find prev(k)
find next(k)
Array n n n n n
Sorted Array n log n log n n 1 log n
Direct Access Array u 1 1 u u
Hash Table n(e) 1(e) 1(a)(e) n n