Question 12
Back to Exercise
In what order does a for-each loop visit the elements of a PriorityQueue?
- A Ascending order
- B Insertion order
- C No particular order (the internal heap array order) Correct
- D Descending order
Correct Answer: Option C
Only poll removes elements in priority order; the iterator walks the heap array.
Discussion & Comments 0
Share your method, a shortcut, or ask about a step you didn't follow.
No comments yet. Be the first to share your solution!