# What is Stack in Data Structure (Explain with diagram)

In this article, we will know what is the stack? Also, we will know the operation of the stack and the position of stack, why the stack is used in data structure? And where the stack is used in computer science.

## What is a stack in a data structure?

A stack is a linear data structure. Which stores the data in sequential order.

Stacking using an array. The stack follows the principle of FILO(first in last out) or LIFO (last in first out).

There are two operations that can be performed with a stack called PUSH and POP.

One END of the stack called the top of the stack.

## What is PUSH and POP in the stack?

#PUSH = This operation is performed when data is inserted into the stack.

#POP = This operation is performed when the data in the stack is removed.

## What is insertion and deletion in the stack?

• Insertion means inserting data inside the stack.
• Deletion means deleting the data inside the stack.

There are two conditions that occurred in a stack called “stack overflow” and “stack underflow”.

## What are stack overflow and stack underflow in the stack?

A stack overflow condition occurs when we perform a PUSH operation. The stack underflow condition occurs when we perform a POP operation. The stack is used in the compiler to solve arithmetic equations.