Introduction to algorithms / Thomas H. Cormen...[etal.].—3rded.
STACK-EMPTY(S) if S.top == 0 return TRUE else return FALSE PUSH(S, x) S.top = S.top + 1 S[S.top] = x POP(S) if STACK-EMPTY(S) error 'underflow' else S.top = S.top - 1 return S[S.top + 1]
//we can implement a stack of at mostnelements withan arraySŒ1::n. DIY-FULL(S) if S.top < n return FLASE else return TRUE DIY-POP(S) if STACK-EMPTY(S) error 'underflow' else if DIY-FULL(S) error 'overflow' else S.top = S.top - 1 return S[S.top + 1]