Briefly explain push operation
Briefly explain push operation
Note: Here, the push operation in the use of a stack is explained below.
Stack Operations:
The two operations that form the majority of the functionality of the stack are the operation of adding items to the stack, and the operation of removing items from the stack.
For historical reasons the operation of adding items to a stack is called “push”. For similar reasons the operation of removing an item from a stack is usually referred to as “pop”.
We must also consider the possibility of errors in developing software. The easiest error to envisage for a stack is when a program tries to remove an item from an empty stack. This condition is called underflow, and if undetected will probably cause a series of mysterious errors before the program crashes. The method that we use to detect this problem is to use an operation called “isEmpty()” to tell us if the stack is empty. If we try and insert data to the completely filled stack, the error condition is usually called overflow. The method that we use to detect this problem is to use an operation called “isFull()” to tell us if the stack is full.
Step by step
Solved in 2 steps