Presented by : Deepuranjan Kumar
MCA 2nd
year(mur2301159)
Stack and Queue Data
Structures
Explore the fundamentals of two essential data structures - the stack
and the queue - and their real-world applications.
by Deepuranjan Kumar
What is a Stack?
Ordered Collection
A stack is an ordered
collection of elements where
items are added and
removed from the same end,
known as the top.
LIFO Principle
The stack follows the Last-In-
First-Out (LIFO) principle,
meaning the most recently
added item is the first to be
removed.
Dynamic Size
Stacks can grow and shrink in size as elements are pushed and
popped, making them a flexible data structure.
Stack Operations
1 Push
Adds an element to the top of the stack.
2 Pop
Removes and returns the top element from the stack.
3 Peek
Inspects the top element without removing it from the stack.
Real-Life Example of a Stack
Plate Stacking
Placing clean plates on top of
each other, with the most recent
plate on top, follows the LIFO
stack principle.
Book Stacking
Stacking books on a shelf, with
the most recent book added to
the top of the pile, is a real-world
stack.
Applications of Stacks
1 Undo/Redo Operations
Stacks are used to
implement undo and redo
functionality in
applications, where the
last action is the first to be
undone.
2 Expression Evaluation
Stacks are used to
evaluate complex
mathematical expressions
by parsing them and
storing the operands and
operators.
3 Function Calls
The call stack in programming languages uses a stack to keep
track of the functions being called and their return addresses.
What is a Queue?
Ordered Collection
A queue is an ordered
collection of elements where
items are added at the back
(enqueue) and removed from
the front (dequeue).
FIFO Principle
The queue follows the First-
In-First-Out (FIFO) principle,
meaning the first element
added is the first to be
removed.
Dynamic Size
Queues can grow and shrink in size as elements are added and
removed, making them a flexible data structure.
Queue Operations
1 Enqueue
Adds an element to the back of the queue.
2 Dequeue
Removes and returns the element from the front of
the queue.
3 Peek
Inspects the element at the front of the queue without
removing it.
Real-Life Example of a Queue
Waiting in Line
People waiting in a line for a
service, such as at a bank or a
theme park, follow the FIFO
queue principle.
Traffic Congestion
Vehicles waiting in a traffic jam
are an example of a real-world
queue, where the first car to
arrive is the first to move.
Applications of Queues
Task Scheduling
Queues are used to manage the
order of tasks or jobs to be
processed, ensuring fairness and
efficiency.
Event Handling
Queues are used to store and
process events in a specific order,
such as in operating systems and
user interfaces.
Resource Management
Queues are used to manage the
allocation of shared resources, such
as network bandwidth or CPU time,
in a fair and efficient manner.
Comparison of Stacks and Queues
Principle Stack (LIFO) Queue (FIFO)
Order of Removal Last item added is the first to be removed First item added is the first to be removed
Common Operations Push, Pop, Peek Enqueue, Dequeue, Peek
Applications Undo/Redo, Expression Evaluation,
Function Calls
Task Scheduling, Event Handling,
Resource Management
DSA MCA Stack-and-Queue-Data-Structures.pptx

DSA MCA Stack-and-Queue-Data-Structures.pptx

  • 1.
    Presented by :Deepuranjan Kumar MCA 2nd year(mur2301159)
  • 2.
    Stack and QueueData Structures Explore the fundamentals of two essential data structures - the stack and the queue - and their real-world applications. by Deepuranjan Kumar
  • 3.
    What is aStack? Ordered Collection A stack is an ordered collection of elements where items are added and removed from the same end, known as the top. LIFO Principle The stack follows the Last-In- First-Out (LIFO) principle, meaning the most recently added item is the first to be removed. Dynamic Size Stacks can grow and shrink in size as elements are pushed and popped, making them a flexible data structure.
  • 4.
    Stack Operations 1 Push Addsan element to the top of the stack. 2 Pop Removes and returns the top element from the stack. 3 Peek Inspects the top element without removing it from the stack.
  • 5.
    Real-Life Example ofa Stack Plate Stacking Placing clean plates on top of each other, with the most recent plate on top, follows the LIFO stack principle. Book Stacking Stacking books on a shelf, with the most recent book added to the top of the pile, is a real-world stack.
  • 6.
    Applications of Stacks 1Undo/Redo Operations Stacks are used to implement undo and redo functionality in applications, where the last action is the first to be undone. 2 Expression Evaluation Stacks are used to evaluate complex mathematical expressions by parsing them and storing the operands and operators. 3 Function Calls The call stack in programming languages uses a stack to keep track of the functions being called and their return addresses.
  • 7.
    What is aQueue? Ordered Collection A queue is an ordered collection of elements where items are added at the back (enqueue) and removed from the front (dequeue). FIFO Principle The queue follows the First- In-First-Out (FIFO) principle, meaning the first element added is the first to be removed. Dynamic Size Queues can grow and shrink in size as elements are added and removed, making them a flexible data structure.
  • 8.
    Queue Operations 1 Enqueue Addsan element to the back of the queue. 2 Dequeue Removes and returns the element from the front of the queue. 3 Peek Inspects the element at the front of the queue without removing it.
  • 9.
    Real-Life Example ofa Queue Waiting in Line People waiting in a line for a service, such as at a bank or a theme park, follow the FIFO queue principle. Traffic Congestion Vehicles waiting in a traffic jam are an example of a real-world queue, where the first car to arrive is the first to move.
  • 10.
    Applications of Queues TaskScheduling Queues are used to manage the order of tasks or jobs to be processed, ensuring fairness and efficiency. Event Handling Queues are used to store and process events in a specific order, such as in operating systems and user interfaces. Resource Management Queues are used to manage the allocation of shared resources, such as network bandwidth or CPU time, in a fair and efficient manner.
  • 11.
    Comparison of Stacksand Queues Principle Stack (LIFO) Queue (FIFO) Order of Removal Last item added is the first to be removed First item added is the first to be removed Common Operations Push, Pop, Peek Enqueue, Dequeue, Peek Applications Undo/Redo, Expression Evaluation, Function Calls Task Scheduling, Event Handling, Resource Management