Build your intuition. Fill in the missing part by typing it in.
Hashmaps, also known as hash tables, are a fundamental data structure in computer science. They provide efficient retrieval, insertion, and deletion of elements by using a technique called ___.
In Python, we can implement a hashmap using a dictionary. Let's take a look at some basic hashmap operations:
1if __name__ == "__main__":
2 # Python code here
3 hashmap = {}
4
5 # Inserting key-value pairs
6 hashmap["Kobe Bryant"] = 24
7 hashmap["LeBron James"] = 23
8
9 # Retrieving values using keys
10 print(hashmap["Kobe Bryant"]) # Output: 24
11 print(hashmap["LeBron James"]) # Output: 23
12
13 # Deleting key-value pairs
14 del hashmap["LeBron James"]
15
16 # Updating values
17 hashmap["Kobe Bryant"] = 8
18
19 # Retrieving updated value
20 print(hashmap["Kobe Bryant"]) # Output: 8
Different keys may produce the same hash code, leading to a ____. One common approach to handle collisions is ____, where each bucket of the hash table contains a linked list of key-value pairs.
The average and worst-case time complexities for hashmap operations depend on the quality of the hash function and the collision handling technique used:
- Retrieval: ___
- Insertion: ___
- Deletion: ___
Fill in the blanks:
The technique used in hashmaps for efficient retrieval, insertion, and deletion of elements is called ___.
Different keys producing the same hash code is known as ____.
One common approach to handle collisions in hashmaps is called ____.
The average and worst-case time complexities for retrieval operation on hashmaps is ___.
The average and worst-case time complexities for insertion operation on hashmaps is ___.
The average and worst-case time complexities for deletion operation on hashmaps is ___.
Write the missing line below.