Stack이란,

Stack의 구조

Stack ADT (스택 추상 자료형)

Stack의 용도(함수 호출 과정)

Untitled

Push 연산

Untitled

push(x)

if isfull() // stack이 꽉 차있는지 확인
		then error "overflow"
		else top ← top + 1 // top = top + 1
				stack[top] ← x // stack[top] = x : 변수 x를 top에 저장

Pop 연산

Untitled

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를 리턴함.

ArrayStack Class