1
1
CSE 326: Data Structures Hash Tables
Hal Perkins Spring 2007 Lecture 16
2
Dictionary Implementations So Far
Delete Find Insert Splay
(amortized)
AVL BST Sorted Array Unsorted linked list
3
Hash Tables
- Constant time accesses!
- A hash table is an array of some
fixed size, usually a prime number.
- General idea:
key space (e.g., integers, strings)
…
TableSize –1 hash function: h(K) hash table
4
Example
- key space = integers
- TableSize = 10
- h(K) = K mod 10
- Insert: 7, 18, 41, 94