0% found this document useful (0 votes)
12 views7 pages

Presentation5

Uploaded by

bhavanibhani626
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views7 pages

Presentation5

Uploaded by

bhavanibhani626
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 7

INTRODUCTION TO STACKS AND QUEUES

PRESENTING BY
DEEKSHA BHVAVANI S
Stacks

 Introduction
A stack is a linear data structure that follows the Last-In-First-Out
(LIFO) principle, meaning the last element added is the first one to
be removed

Operations
1. Push operation
2. Pop operation
 1. Push: Add an element to the top of the stack
 Steps
 1. Check if the stack is full
 2. Allocate memory for the new element.
 3. Add the new element to the top of the stack
 4. Update the stack pointerto point to the new element.
Example: Initial Stack: [1, 2, 3]
Push Element: 4
Resulting Stack: [1, 2, 3, 4]
 2. Pop: Remove the top element from the stack
 Steps:1. Check if the stack is empty.
 2. Store the top element in a temporary variable (optional)
 3. Remove the top element from the stack.
 4. Update the stack pointer (top index) to point to the previous element.
 Example
 Initial Stack: [1, 2, 3, 4]
 Popped Element: 4
 Resulting Stack: [1, 2, 3]
 Applications of stacks
A real-world example of a stack is a pile of books, plates, or money,
where yo u can only add or remove items from the top.
Introduction To Queue

 A queue is a linear data structure that follows the First-In-First-Out


(FIFO) principle, meaning the first element added is the first one to be
removed.

 A queue is open at both ends. One end is provided for the insertion
of data and the other end for the deletion of data.
A queue being an Abstract Data Structure provides the following operations for manipulation on the
data elements:
•isEmpty(): To check if the queue is empty
•isFull(): To check whether the queue is full or not
•dequeue(): Removes the element from the frontal side of the queue
•enqueue(): It inserts elements to the end of the queue
•Front: Pointer element responsible for fetching the first element from the queue
•Rear: Pointer element responsible for fetching the last element from the queue

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy