Bird
0
0

Which design pattern is most suitable for managing different vehicle sizes and corresponding parking spots in a parking lot system?

hard📝 Trade-off Q8 of 15
LLD - Design — Parking Lot System
Which design pattern is most suitable for managing different vehicle sizes and corresponding parking spots in a parking lot system?
ADecorator pattern to add features to parking tickets
BSingleton pattern to ensure one parking lot instance
CObserver pattern to notify vehicles about spot availability
DStrategy pattern to select parking spot allocation algorithm
Step-by-Step Solution
Solution:
  1. Step 1: Understand problem requirements

    Different vehicle sizes require different allocation strategies.
  2. Step 2: Match design pattern

    The Strategy pattern allows selecting or changing the allocation algorithm dynamically.
  3. Final Answer:

    Strategy pattern to select parking spot allocation algorithm -> Option D
  4. Quick Check:

    Check if pattern supports flexible allocation logic [OK]
Quick Trick: Use Strategy pattern for flexible allocation algorithms [OK]
Common Mistakes:
MISTAKES
  • Choosing Singleton which controls instance creation, not allocation
  • Using Observer which is for event notification
  • Selecting Decorator which adds responsibilities, not allocation logic

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More LLD Quizzes