+3 votes
in Class 12 by kratos

What is stack? Write an algorithm for POP operation.

1 Answer

+6 votes
by kratos
 
Best answer

stack is an ordered collection of items in which items may be inserted and deleted at one end.
Algorithm for POP operation
PUSH( STACK, TOP, ITEM)
Step 1: if TOP = 0 then
PRINT “stack is empty”
Exit
End of if
Step 2: ITEM = STACK[POP]
Step 3: TOP = TOP -1
Step 4: Return

...