Hash Table Size (Module 7) Flashcards
What happens if the table size is a composite number? (m = 10)
keys may have hash values that repeatedly collide due to common factors with m
Why do prime numbers give better distribution of hash values?
they have no divisors other than 1 and themselves (minimizes patterns)
A prime ‘m’ guarantees m-1 is _________ by many keys
not divisible
What type of bias produces a biased distribution if m is composite?
modular arithmetic bias
What is the best-case time complexity for hash tables?
O(1)
What is the worst-case time complexity for hash tables?
O(n)
What is the space complexity for separate chaining and open addressing?
O(m)
What is the time complexity for rehashing?
O(n)
What is the space complexity for rehashing?
O(2m)
Choosing a table size m as a prime number is crucial in all probing techniques because?
1) reduces clustering
2) ensures full coverage
3) improves hash function effectiveness
4) prevents cycles
What are 3 ideas for extra optimization?
1) take in better keys
2) optimize the bucket
30 modify the array’s internal capacity