Hash Tables
Overview
Hash tables are also data structures that can be used
to implement finite sets and mappings. Their worst-case performance is
not very good, and their analysis is complicated — but they work
extremely well in practice (especially when used to represent a set or
mapping that does not change very much) and they can be proved to have
very good “expected” performance under certain assumptions.
Two kinds of hash tables — “hash tables with chaining”
and “hash tables with open addressing” — will be presented and
discussed. A few other kinds of hash tables will be more briefly described.
Lecture #12: Hash Tables — Part One
Required Reading
- Lecture Notes:
[ PDF ]
[ Video ]
- Supplemental Material: Average-Case Analysis for Hash
Tables with Chaining:
[ PDF ]
Lecture Presentation
Code Supplied with This Lecture
Hash Functions for Hash Tables with Chaining
A Hash Table with Chaining
Implementation of a Set Using a Hash Table with Chaining
Implementation of a Mapping Using a Hash Table with Chaining
Reading Exercise #3: Hash Functions
Lecture #13: Hash Tables — Part Two
Required Reading
- Lecture Notes:
[ PDF ]
[ Video ]
- Supplemental Material: Average-Case Analysis of Hashing with
Open Addressing:
[ PDF ]
Lecture Presentation
Code Supplied with This Lecture
Hash Functions for Hash Tables with Open Addressing
Implementation of a Hash Table with Open Addressing
Reading Exercise #4: Randomization and Hashing
Tutorial #12: Hash Tables
Test Results
Code To Be Completed
Implementation of a Set (Use After Completing the Above)
Implementation of a Mapping (Use After Completing the Above