Hash Table Size (Module 7) Flashcards

1
Q

What happens if the table size is a composite number? (m = 10)

A

keys may have hash values that repeatedly collide due to common factors with m

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

Why do prime numbers give better distribution of hash values?

A

they have no divisors other than 1 and themselves (minimizes patterns)

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

A prime ‘m’ guarantees m-1 is _________ by many keys

A

not divisible

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

What type of bias produces a biased distribution if m is composite?

A

modular arithmetic bias

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

What is the best-case time complexity for hash tables?

A

O(1)

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

What is the worst-case time complexity for hash tables?

A

O(n)

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

What is the space complexity for separate chaining and open addressing?

A

O(m)

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

What is the time complexity for rehashing?

A

O(n)

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

What is the space complexity for rehashing?

A

O(2m)

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

Choosing a table size m as a prime number is crucial in all probing techniques because?

A

1) reduces clustering
2) ensures full coverage
3) improves hash function effectiveness
4) prevents cycles

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

What are 3 ideas for extra optimization?

A

1) take in better keys
2) optimize the bucket
30 modify the array’s internal capacity

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