You are solving BFS on a graph. Which collection should you usually use for the frontier?
Practice this question from Quiz: Collection Comparisons, with options and an explanation.
Question
You are solving BFS on a graph. Which collection should you usually use for the frontier?
Option A — Correct answer
ArrayDeque used as a queue
BFS requires FIFO behavior.
Option B
HashMap only
Option C
StringBuilder
Option D
Optional
Explanation
BFS needs FIFO behavior, and ArrayDeque is a strong modern Java queue choice.