Algorithm for deleting an item into the stack (POP)


Step 1: IF TOP = NULL
	   PRINT UNDERFLOW
	[END OF IF]
Step 2: SET ITEM = STACK[TOP]
Step 3: SET TOP = TOP-1
Step 4: END

Explanation

  • In Step 1, we first check for the UNDERFLOW condition.
  • In Step 2, the value of the location in the stack pointed by TOP is stored in ITEM.
  • In Step 3, the value is stored in the stack at the location pointed by TOP.

The function of Pop operation is given as :

void pop( )
{
  int item ;
  if (top >= 0)
  {
	item = stack [top] ;
	top = top - 1 ;
	printf ("No deleted is = %d", item)
  }
  else
    printf ("Stack is empty") ;
}