스택(stack) : 쌓아놓은 더미
LIFO(Last In Firts Out)
→ 가장 최근에 들어온 데이터가 가장 먼저 나감.
push(x)
if isfull() // stack이 꽉 차있는지 확인
then error "overflow"
else top ← top + 1 // top = top + 1
stack[top] ← x // stack[top] = x : 변수 x를 top에 저장
pop()
if isEmpty() // 비어있는지 확인
then error "underflow"
else e ← data[top] // e = data[top] : top를 변수 e에 저장
top ← top -1 // top = top - 1
return e // top의 값인 e를 리턴함.