logo

Question detail

A stack contains, from bottom to top, A, B, and C. What value is returned by peek, and what happens to the stack?

Try the question, check the answer, then read the explanation to understand the curriculum point.

At a glance

MCQ

Type

practice

Style

Topic

Stacks

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?.

  1. A.A is returned and removed
  2. B.B is returned and removed
  3. C.C is returned and remains in the stack
  4. D.C is returned and removed

Model answer

What a good answer should say

  • C is returned and remains in the stack

Explanation

Why this works

C is the top element. Peek, also called top, returns the top value without removing it.

Common mistake

No common mistake is linked to this question yet.

Related flashcards

No flashcards are published for this page yet.

Related practice questions

No questions are published for this page yet.