AlgoScope

Peek

Read the top item without removing it.

Stack and queue algorithms, algorithm, beginner
Peek shows the top item, 3. Nothing changes.53bottomtoptop
Peek shows the top item, 3. Nothing changes.53bottomtoptop

Stack: Push, pop, peek

Step, step 6 of 10

peek shows 3 without removing it.

Cost

Best
O(1)
Average
O(1)
Worst
O(1)
Space
O(1)

Before this

Taught by the same lesson

Stack covers these too, in the same run.