0% found this document useful (0 votes)
6 views

Stack and Queue in Data Structure

Uploaded by

bruteforce453
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views

Stack and Queue in Data Structure

Uploaded by

bruteforce453
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 8

Stack and Queue in Data Structure

Data structures are the foundation of computer science, enabling efficient organization and manipulation of
information. In this presentation, we'll explore the fundamental concepts of stacks and queues, their operations, and
their practical applications.
by Brute Force
What is a Stack?
LIFO Structure Efficient Access Versatile Applications
A stack is a linear data structure Stacks provide efficient access to Stacks are widely used in various
that follows the Last-In-First-Out the top element, making them computer science domains, from
(LIFO) principle, where the last ideal for tasks like expression programming languages to
element added is the first to be evaluation, function calls, and operating systems and beyond.
removed. memory management.
Stack Operations: Push,
Pop, Peek
1 Push
Adding an element to the top of the stack.

2 Pop
Removing the top element from the stack.

3 Peek
Accessing the top element without removing it.
Applications of Stack
1 Expression Evaluation 2 Function Calls 3 Memory Management
Stacks are used to evaluate Stacks store return addresses Stacks are used to allocate
arithmetic and logical and function parameters and deallocate memory for
expressions by parsing them during function calls, enabling variables and function calls in
and storing operands and proper execution flow. programming languages.
operators.

4 Undo/Redo Operations
Stacks can keep track of user actions, allowing for easy implementation of undo and redo functionality.
What is a Queue?
FIFO Structure Efficient Access Versatile Applications
A queue is a linear data structure Queues provide efficient access Queues are widely used in
that follows the First-In-First-Out to the front and rear elements, various computer science
(FIFO) principle, where the first making them useful for tasks like domains, from operating systems
element added is the first to be task scheduling and resource to network protocols and
removed. management. beyond.
Queue Operations:
Enqueue, Dequeue
1 Enqueue
Adding an element to the rear of the queue.

2 Dequeue
Removing the element from the front of the queue.
Applications of Queue
1 Task Scheduling 2 Simulation and Modeling 3 Breadth-First Search
(BFS)
Queues are used to manage Queues are used to simulate
the order of tasks or real-world scenarios, such as Queues are a fundamental
processes, ensuring fairness customer service lines or data structure used in the
and efficient resource network traffic. implementation of BFS
allocation. algorithms for graph traversal.

4 Buffering and Caching


Queues can be used to temporarily store data, improving performance in scenarios like multimedia streaming
or network communication.
Comparison: Stack vs. Queue
Stack Queue

Follows the Last-In-First-Out (LIFO) principle. Follows the First-In-First-Out (FIFO) principle.

Efficient access to the top element. Efficient access to the front and rear elements.

Commonly used for expression evaluation and function calls. Commonly used for task scheduling and resource
management.

You might also like