Push Operation On Stack

Push ( ):
Description: Here STACK is an array with MAX locations. TOP points to the top most element and ITEM is
the value to be inserted.


  1.  If (TOP == MAX) Then [Check for overflow]
  2.  Print: Overflow
  3.  Else
  4.  Set TOP = TOP + 1 [Increment TOP by 1]
  5.  Set STACK[TOP] = ITEM [Assign ITEM to top of STACK]
  6.  Print: ITEM inserted
  7. [End of If]
  8.  Exit
SHARE

About Abhishek

    Blogger Comment
    Facebook Comment

0 comments:

Post a Comment