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.
Description: Here STACK is an array with MAX locations. TOP points to the top most element and ITEM is
the value to be inserted.
- If (TOP == MAX) Then [Check for overflow]
- Print: Overflow
- Else
- Set TOP = TOP + 1 [Increment TOP by 1]
- Set STACK[TOP] = ITEM [Assign ITEM to top of STACK]
- Print: ITEM inserted
- [End of If]
- Exit
0 comments:
Post a Comment