What does `peek()` do in a Deque context?

  1. Removes the head element
  2. Returns head element without removing it
  3. Throws exception if deque is empty
  4. Returns the last element
Correct answer Returns head element without removing it

Explanation

`peek()` retrieves but does not remove the head of the deque.

Update: Admin added a tag on this question

Topics

By Admin · · 26 views