Hash Maps Flashcards
What is a Load Factor?
Property of a hash map that determines when the hash map should be resized.
How is load factor calculated?
The load factor is calculated by dividing the number of
key-value pairs in the hash map by the length of the array
When is a hash map resized?
When the load factor exceeds a certain threshold.
What is the best case big O for searching in a hash map?
Because hash maps use the hash code of the key to find the associated value, searches tend to be O(1).
What is the best case big O for adding in a hash map?
O ( 1 )
What is the best case big O for removing from a hash map?
O ( 1 )
What is the worst case big O for removing, searching, and adding to a hash map?
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)