Multiple choice technology programming languages

Which of the following classes would provide the most efficient implementation of a First In First Out queue?

  1. ArrayList

  2. LinkedHashMap

  3. LinkedHashSet

  4. LinkedList

  5. TreeMap

  6. Vector

Reveal answer Fill a bubble to check yourself
D Correct answer
Explanation

A FIFO queue requires efficient add-at-end and remove-from-front operations. LinkedList provides O(1) for both operations. ArrayList requires O(n) for front removal. LinkedHashMap/LinkedHashSet/TreeMap don't provide queue semantics. Vector has same issues as ArrayList. Option D (LinkedList) is optimal.