Bird
Raised Fist0

Which data structure is best suited to store fine rates for different violation types?

easy🧠 Conceptual Q2 of Q15
LLD - Design — Library Management System

Which data structure is best suited to store fine rates for different violation types?

AHash map with violation type as key and fine amount as value
BLinked list of user names
CArray of random numbers
DStack of recent transactions
Step-by-Step Solution
Solution:
  1. Step 1: Identify the need to map violation types to fines

    We need quick lookup of fine amount by violation type, so a key-value structure is ideal.
  2. Step 2: Choose the appropriate data structure

    A hash map (dictionary) allows fast access by violation type keys.
  3. Final Answer:

    Hash map with violation type as key and fine amount as value -> Option A
  4. Quick Check:

    Best data structure = Hash map [OK]
Quick Trick: Use key-value maps for quick fine lookups [OK]
Common Mistakes:
MISTAKES
  • Using unrelated data structures like linked lists
  • Choosing arrays without keys

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More LLD Quizzes