AlgoThrive
← All structures

Stack

PushedPopping

stack

LIFO — last in, first out

↓ top

stack is empty

↑ bottom (fixed)

pseudocode

push(x)
top++; a[top] = x
pop()
x = a[top]; top--
return x

Frame 1 / 12

Start

empty stack

4

Comma-separated: "push N" or "pop". 1–12 operations, values 1–99.