Hash Maps and Sets: Entity Lookup and State Tracking Quiz

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.

  1. Identifying Fast Lookup Structures

    Which data structure allows you to retrieve an entity by its unique identifier in constant time?

    1. Stack
    2. Hash map
    3. Array
    4. Hash mop
    5. Linked list
  2. State Tracking with Sets

    How does using a set help track which components are currently active in a system?

    1. By keeping components in a sorted order automatically
    2. By mapping component names to their values
    3. By using a heap for ordering
    4. By duplicating each component for verification
    5. By storing each active component's identifier only once
  3. Hash Map Key Selection

    When using a hash map for entity lookups, what is commonly used as the key?

    1. Arbitrary number
    2. Unique entity ID
    3. Component value
    4. Array index
    5. Untique entity ID
  4. Duplicate Prevention in Sets

    Why would you use a hash set to store component states instead of a list?

    1. To increase memory usage
    2. To guarantee insertion order
    3. To sort entries by default
    4. To automatically remove duplicate entries
    5. To allow direct value mapping
  5. Checking Membership

    Which operation does a hash set optimize for when checking if an entity has a specific component?

    1. Sorting elements
    2. Membership test
    3. Reverse iteration
    4. Merging values
    5. Mumbersip test
  6. Hash Map Value Usage

    In a hash map used for component lookups, what is typically stored as the value?

    1. Numberic entity key
    2. List of all entity IDs
    3. Hash function result
    4. Duplicate components
    5. Component object or reference
  7. Adding to a Set

    What happens if you add the same entity’s identifier twice to a hash set tracking visited entities?

    1. An error is thrown
    2. Both are stored causing duplicates
    3. The set is automatically cleared
    4. Only one occurrence is kept
    5. One occurrence is kepped
  8. Removing from a Hash Map

    Which action removes an entity’s component from a hash map?

    1. Deleting its kay-value pair
    2. Incrementing its value
    3. Sorting the map
    4. Deleting its key-value pair
    5. Clearing the entire map
  9. Hash Set Use Case

    If you want to ensure no entity is processed more than once during traversal, which structure is most efficient?

    1. Harsh set
    2. Stack
    3. Array
    4. Queue
    5. Hash set
  10. State Change Detection

    What is a simple way to detect if the state of an entity has changed using sets?

    1. Sort all identifiers and compare
    2. Check if its identifier apears in the set of modified entities
    3. Iterate through all possible entities
    4. Search its value in an unsorted list
    5. Check if its identifier appears in the set of modified entities