Stacks Concept in Data
Structure
By Umera Sulthana S
Introduction to Stacks
A stack is a linear data structure that follows the
.Last In, First Out (LIFO) principle
The main operations of a stack include push, pop,
.and peek
Stacks are used in various applications, including
expression evaluation and backtracking
.algorithms
Stacks representation
Stack Operations
1. Push Operation on Stack
• Adds an item to the stack. If the stack is
full, then it is said to be an Overflow
condition.
• The elements can be pushed into the
stack till we reach the capacity of the
stack.
2
2. Pop Operation in Stack
Removes an item from the stack. The items
are popped in the reversed order in which
they are pushed. If the stack is empty.
Then it is said to be an Underflow
condition.
3. Top or Peek Operation on Stack
Returns the top element of the stack.
Before returning the top element from the
stack, we check if the stack is empty
Stack Implementations
• Stacks can be implemented using
arrays or linked lists.
• An array-based stack has a fixed size,
leading to potential overflow.
• A linked list based stack can grow
dynamically, with no overflow issues
unless memory is exhausted.
3
Applications of Stacks
1. Stacks are commonly used in function call management
through call stacks.
2. They are essential in parsing expressions and syntax
checking in compilers.
3. Stacks facilitate backtracking algorithms, such as in
problem solving and puzzle games.
Advantages of stacks
• A primary advantage of stacks is their simplicity and ease of
implementation.
• Stacks also provide efficient memory usage for small data sets.
• However, their fixed size in array implementations can lead to overflow
and wasted space.
Thank You......
Presented by Umera Sulthana S