Question
When should a Java developer choose Adjacency List vs Adjacency Matrix deliberately?
- Choose Adjacency List vs Adjacency Matrix mainly when you want to postpone validation and fix problems manually later.
- Choose an adjacency list for most interview graph problems unless the graph is dense or direct edge lookup dominates.
- Choose Adjacency List vs Adjacency Matrix whenever you want the code to look more advanced, even if the design gets less clear.
- Choose Adjacency List vs Adjacency Matrix only to avoid modeling domain rules explicitly in Java code.
Hint
Think about the production scenario where the choice genuinely improves the code.
Answer and rationale
Correct answer: B. Choose an adjacency list for most interview graph problems unless the graph is dense or direct edge lookup dominates.
Choose an adjacency list for most interview graph problems unless the graph is dense or direct edge lookup dominates. Interviewers often ask this to see whether you can connect the concept to real design decisions.
Track: Java