Test your understanding of how hash maps and sets are used for entity/component lookups and basic state tracking with this 10-question quiz. Perfect for learners building foundational knowledge in these data structures.
Identifying Fast Lookup Structures
Which data structure allows you to retrieve an entity by its unique identifier in constant time?
- Stack
- Hash map
- Array
- Hash mop
- Linked list
State Tracking with Sets
How does using a set help track which components are currently active in a system?
- By keeping components in a sorted order automatically
- By mapping component names to their values
- By using a heap for ordering
- By duplicating each component for verification
- By storing each active component's identifier only once
Hash Map Key Selection
When using a hash map for entity lookups, what is commonly used as the key?
- Arbitrary number
- Unique entity ID
- Component value
- Array index
- Untique entity ID
Duplicate Prevention in Sets
Why would you use a hash set to store component states instead of a list?
- To increase memory usage
- To guarantee insertion order
- To sort entries by default
- To automatically remove duplicate entries
- To allow direct value mapping
Checking Membership
Which operation does a hash set optimize for when checking if an entity has a specific component?
- Sorting elements
- Membership test
- Reverse iteration
- Merging values
- Mumbersip test
Hash Map Value Usage
In a hash map used for component lookups, what is typically stored as the value?
- Numberic entity key
- List of all entity IDs
- Hash function result
- Duplicate components
- Component object or reference
Adding to a Set
What happens if you add the same entity’s identifier twice to a hash set tracking visited entities?
- An error is thrown
- Both are stored causing duplicates
- The set is automatically cleared
- Only one occurrence is kept
- One occurrence is kepped
Removing from a Hash Map
Which action removes an entity’s component from a hash map?
- Deleting its kay-value pair
- Incrementing its value
- Sorting the map
- Deleting its key-value pair
- Clearing the entire map
Hash Set Use Case
If you want to ensure no entity is processed more than once during traversal, which structure is most efficient?
- Harsh set
- Stack
- Array
- Queue
- Hash set
State Change Detection
What is a simple way to detect if the state of an entity has changed using sets?
- Sort all identifiers and compare
- Check if its identifier apears in the set of modified entities
- Iterate through all possible entities
- Search its value in an unsorted list
- Check if its identifier appears in the set of modified entities