Separate Chaining (Module 7) Flashcards

1
Q

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?

A

separate chaining

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

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?

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What are 2 advantages for separate chaining?

A

1) multiple keys can be in the same index without probing or rehashing
2) linked lists can dynamically grow (avoiding overflow)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What are 2 disadvantages for separate chaining?

A

1) needs extra memory for pointers
2) performance degradation (more collisions = more degradation)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What should you do to prevent performance degradation and have efficient lookup times?

A

keep the average length of the chains small

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

When is resizing typically done?

A

When a load factor exceeds a certain threshold

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What is the formula for a load factor?

A

of elements in table / total # of buckets in the table

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

How does resizing work?

A

create a larger table and rehash all elements into new table

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Why do we rehash?

A

to make sure elements are distributed to maintain uniformity and reduce collisions

How well did you know this?
1
Not at all
2
3
4
5
Perfectly