Stacks are known as last in first out data structure (LIFO). In this the last item pushed on the stack is the first item popped from the stack. In stack the insertion and deletion can be taken placed at one only end called stack’s top. A stack is a non-primitive linear data structure in which the insertion and the deletion of the elements take place from only one end, known as the top.
The fundamental operations that can be performed on stack are push and pop. Push operation causes a value to be stored in (pushed onto) the stack; whereas, Pop retrieves and removes a value from the stack. PUSH is an operation used to add a new element in to a stack. When implementing the push operation, overflow condition of a stack is to be checked. Insert a new data item on the TOP. TOP is set to a newly added item.
Pop is an operation used to remove an element from the TOP of the stack. When implementing the pop operation, underflow condition of a stack is to be checked. Stack can be implemented in two ways As an Array and as a Linked List.