Basics of Stack Data Structure | PLM Developer

The dictionary meaning for word Stack is “A pile of Objects neatly arranged.” As the definition suggests, you can assume that Objects stored in this data structure are a pile of objects.

A stack is a linear data structure, which means elements or objects in this data structure arranged sequentially. In Stack, operations performed in LIFO(Last In First Out) or FILO(First In Last Out).

Basic operations performed using the Stack data structure are push, pop, peek, or top.

Basic Operations:

push: The push operation adds an element into the Stack. If we try to add elements into full-stack, then it leads to Stack Over Flow condition.

pop: The pop operation removes an element from the top of the Stack. If we try to remove an item from an empty Stack, then it leads to Stack Under Flow condition.

peek: (or Top) Always returns the top of the element.

Understanding Stack Data Structure:

Let us consider a simple example to understand Stack. In a classroom teacher asked students to keep their assignment notebooks on the table by their roll number. Students, one by one, came and kept their assignment notebooks on the table. In this case, the student having the First roll number notebook will be there at the bottom and the student having the Last roll number notebook at the top of the pile. So, the teacher will verify the assignment notebook of the last roll number first and the first roll number last.
Similarly, In the Stack data structure, the first inserted element is at the bottom of the Stack, and the Last added item is at the top of the Stack.

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top