Exam-style question
Try this first
A stack contains, from bottom to top, A, B, and C. What value is returned by peek, and what happens to the stack?.
- A.A is returned and removed
- B.B is returned and removed
- C.C is returned and remains in the stack
- D.C is returned and removed
Answer and explanation
Concise answer
C is returned and remains in the stack
Why this is correct
C is the top element. Peek, also called top, returns the top value without removing it.
Use the concise answer above for a quick check, then reveal the full model answer and detailed explanation.
Common mistake
No common mistake is linked to this question yet.
