Write the steps involved in the insertion and deletion of an element in the stack.

Push:

  • Increment the variable top so that it can refer to the next memory allocation
  • Copy the item to the at the array index value equal to the top
  • Repeat step 1 and 2 until stack overflows
    Pop:
  • Store the topmost element into the an another variable
  • Decrement the value of the top
  • Return the topmost element