Hash Maps Flashcards

1
Q

What is a Load Factor?

A

Property of a hash map that determines when the hash map should be resized.

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

How is load factor calculated?

A

The load factor is calculated by dividing the number of

key-value pairs in the hash map by the length of the array

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

When is a hash map resized?

A

When the load factor exceeds a certain threshold.

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

What is the best case big O for searching in a hash map?

A

Because hash maps use the hash code of the key to find the associated value, searches tend to be O(1).

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

What is the best case big O for adding in a hash map?

A

O ( 1 )

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

What is the best case big O for removing from a hash map?

A

O ( 1 )

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

What is the worst case big O for removing, searching, and adding to a hash map?

A

If the keys have a limited range of hash codes, or collisions occur for other reasons, then adding, searching, and removing
from a hash map is O(n)

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