Hash Tables - 1
- Combine the vector and list ideas
- Use hash function to convert KeyType to unsigned int
- Vector v indexed on hash value
- Vector elements are TList<pair> objects (called buckets)
- Search Algorithm:
1: compute hash value hval for key (mod vector size) | O(1) |
2: access bucket at that vector index | O(1) |
3: search this bucket | O(v[hval].Size()) [worst case] |
- Table:: Insert(), Includes(), Remove() all use this search algorithm
|