Separate Chaining (Module 7) Flashcards
Which collision resolution technique stores the hash table as an array of bucket where each bucket containers a pointer to a linked list that holds all of the elements hashing to that index?
separate chaining
Seperate Chaining Mechanism:
1) What first happens to the new key?
2) If the bucket at an index is empty, where does the new key go?
3) If a collision occur, what happens to the new key?
1) it’s hashed using a hash function to compute the index
2) it’s added as the first element of the list
3) it’s added to the list in that bucket
What are 2 advantages for separate chaining?
1) multiple keys can be in the same index without probing or rehashing
2) linked lists can dynamically grow (avoiding overflow)
What are 2 disadvantages for separate chaining?
1) needs extra memory for pointers
2) performance degradation (more collisions = more degradation)
What should you do to prevent performance degradation and have efficient lookup times?
keep the average length of the chains small
When is resizing typically done?
When a load factor exceeds a certain threshold
What is the formula for a load factor?
of elements in table / total # of buckets in the table
How does resizing work?
create a larger table and rehash all elements into new table
Why do we rehash?
to make sure elements are distributed to maintain uniformity and reduce collisions