The Gateway to Computer Science Excellence
0 votes
41 views
STACK-EMPTY(S)
1     if S.top == 0
2     return TRUE
3     else return FALSE

PUSH(S , x)
1     S.top = S.top + 1
2     S[S.top] = x

POP(S)
1     if STACK-EMPTY(S)
2     error “underflow”
3     else S.top = S.top – 1
4     return S[S.top + 1]

illustrate the result of each operation in the sequence $PUSH(S,4), PUSH(S,1),PUSH(S,3),POP(S),PUSH(S,8),POP(S)$ on an initially empty stack $S$ stored in array $S[1...6]$

in Algorithms by Boss (41.9k points) | 41 views

1 Answer

0 votes
STACK
4    
4 1  
4 1 3
4 1  
4 1 8
4 1  

 

by Active (1.3k points)

Related questions

Quick search syntax
tags tag:apple
author user:martin
title title:apple
content content:apple
exclude -tag:apple
force match +apple
views views:100
score score:10
answers answers:2
is accepted isaccepted:true
is closed isclosed:true
50,647 questions
56,492 answers
195,439 comments
100,710 users