**In this module, we will cover**

- The core idea behind the Stack
- Fundamental operations of a Stack
- Array implementation of a Stack in c++
- Explanation of code

A stack is a list with the restriction that insertions and deletions can be performed in only one position, namely the end of the list called the top. An explanatory video from YouTube.

Stack implements LIFO( last in first out ) or FILO( first in last out ) policy.

### Fundamental operations

- push ( equivalent to insert ): data is inserted at the top position
- pop ( equivalent to delete ): deletes the most recently inserted element

Let’s consider the spring-loaded stacks of plates used in cafeterias, the order in which plates are popped from the stack is the reverse of the order in which they are pushed onto the stack since only the top plate is accessible.

**Array implementation of stack**

#### Basic operations :

- push( x ) : insert element x at the top of a stack
- pop( ) : removes an element from the top of a stack
- topElement( ) : access the top element of a stack
- isEmpty( ) : check whether a stack is empty
- size( ) : determines the current size of a stack

#### Code :

#### Explanation of code :

### Practice Problems

- Balanced Brackets ( HackerEarth )
- Stack and Queue ( HackerEarth )
- Minimum add to make parenthesis valid ( HackerEarth )
- Equal Stacks ( Hackerrank )
- Game of two stacks ( Hackerrank )

That’s all for this article, after completing Linked List we will implement this again using a Linked list. In the next article, we will discuss the **Queue**.

So, for now, practice the above problems and** if you get stuck then ask your questions through comment section** or if you have **any content** related to the topics discussed above and want to add here, then you can mention in the comment section for which we will be thankful to you.

Thank You for Reading