Test your understanding of basic concepts related to hash maps and sets, including their operations, use cases, and core properties.
Hash Map Definition
Which of the following best describes the main purpose of a hash map?
- To display items in a queue
- To store key-value pairs for fast retrieval
- To arrange items in a sorted sequence
- To store only unique values without any associated keys
- To process numerical data for graphs
Set Characteristic
What is a distinguishing characteristic of a set compared to a list?
- Sets do not allow duplicate elements
- Sets use tuple indexing for access
- Sets maintain elements in insertion order
- Sets support sorting automatically
- Sets require each element to have a key
Hash Function Purpose
What role does a hash function play in a hash map?
- It displays the values as a tree structure
- It translates keys to storage locations within the map
- It removes duplicate keys automatically
- It sorts the keys in alphabetical order
- It compresses the data for storage
Common Hash Map Operation
If you want to find out if a key exists in a hash map, which operation would you use?
- Pop
- Enqueue
- Concat
- Push
- Lookup
Duplicate Handling in Sets
What will happen if you try to add a duplicate element to a set?
- All elements of the set are deleted
- An error is thrown immediately
- The set becomes a list type
- Only one duplicate is kept alongside the original
- The set remains unchanged
Hash Map Collision
What is a collision in the context of hash maps?
- When a set contains an invalid element
- Attempting to retrieve a key that does not exist
- Two different keys producing the same hash index
- Merging two sets with common elements
- A map storing only integers
Set Membership Check
Given a set containing {3, 6, 8}, which operation checks if the number 6 is present?
- Fetching by index
- Concatenation
- Sorting
- Push
- Membership test
Mutable Values in Hash Maps
What does it mean for values in hash maps to be mutable?
- The values can be changed after they are assigned
- Values cannot be numbers
- Each value is automatically sorted
- Values are removed after retrieval
- Values must always be unique
Performance of Search
Which data structure typically allows for fastest search of elements: set, list, or tuple?
- Tuple
- Stack
- Set
- List
- Queue
Key Requirement in Hash Maps
What type of object is typically required for use as a key in a hash map?
- A mutable set
- A string of variable length only
- An immutable object
- A list of numbers
- A floating-point number only