Stack Concept OverviewPritesh
Concept Of Stack | Definition
We know that the Stack is LIFO Structure i,e Last in First Out. It is very useful data structure in C Programming. Stack can be implemented using the Linked List or Array.
Must Read : Array Representation of Stack
What is Stack ?
- Stack is LIFO Structure [ Last in First Out ]
- Stack is Ordered List of Elements of Same Type.
- Stack is Linear List
- In Stack all Operations such as Insertion and Deletion are permitted at only one end called Top
Visual Representation of Stack :
Consider Stack with following details –
|Size of the Stack||6|
|Maximum Value of Stack Top||5|
|Minimum Value of Stack Top||0|
|Value of Top when Stack is Empty||-1|
|Value of Top when Stack is Full||5|
View 1 : When Stack is Empty
When Stack is said to empty then it does not contain any element inside it. Whenever the Stack is Empty the position of topmost element is -1.
View 2 : When Stack is Not Empty
Whenever we add very first element then topmost position will be incremented by 1. After adding First Element top = 0.
View 3 : After Deletion of 1 Element Top Will be Decremented by 1
Position of Top and Its Value :
|Position of Top||Status of Stack|
|-1||Stack is Empty|
|0||First Element is Just Added into Stack|
|N-1||Stack is said to Full|
|N||Stack is said to be Overflow|