Array and linked representation of stacks
Implementing stacks using an array
Step 1: START-This class will create a pointer top that will contain all the operations that we will need to perform when storing data.
Step 2: Push()-This function returns data to the stack. It first checks if the top-of-the-stack is full or not.
Step 3: Pop()-This function will remove data from the stack if the top == -1 is true. It will also check if the stack is empty if the element on the top is null.
Step 4: isEmpty()- function to check if the stack is empty.
Example:

Implementing stacks using linked lists
Step 1: START – Firstly, we initialize the node. It is the main component of an out-of-connected list. It contains a variable to store data and a pointer to the next node.
Step 2: Push() – The push function is used to insert data into a stack if the heap is full. If this operation failed, then we can’t push more data into the new node.
Step 3: Pop() – The pop() function is used to get rid of a Node from the linked list. It sends the data value to the top of the pointer and returns the data value once again.
Step 4: Display() – The display function is used to print the data in the nodes. Iterated through all the nodes until the last one is reached.
Example: