0% found this document useful (0 votes)
18 views8 pages

8 - 9 Data Structure Stake Queue 1

Uploaded by

mahiratnakar01
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)
18 views8 pages

8 - 9 Data Structure Stake Queue 1

Uploaded by

mahiratnakar01
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/ 8

NAVODAYA VIDYALAYA SAMITI,

NOIDA

E-CONTENT FOR CLASS XII

(COMPUTER SCIENCE: 083)

CHAPTER :
DATA STRUCTURE –STACK AND QUEUE USING
LIST

Prepared By,
R S KUSHWAHA (PGT IT)
JNV SAGAR
Data Structure
 Data Structure is a way of collecting and organizing data in such
a way that we can perform operations on these data in an
effective way.
 Types of Data Structures in Python:

Data
Structures in
Python

Built-in-Data User-Defined Data


Structures Structures

List Tuple Dictionary Set Stack Queue Tree Linked List


Stack
 Stack is a data structure in which insertion and deletion of elements can be
done, only at the one end that is called top.
 Stack follows Last-In-First-Out(LIFO) principle i.e., the element which is
inserted last in the stack, will be deleted first from the stack.
 Examples of stack:

Stack of Pizzas
Stack of Books Stack of Coins
Stack Operations
Push()- Inserting element at the top of stack.
Open end
Push 10 Push 20 Push 30 Push 40 Push 50

50 T
40 40
T
30 T 30 30
20 20 20 20
T
10 T 10 10 10 10
Empty Stack

Pop()- deleting element from the top of stack. Here T stands for Top

T 50 Pop 50 Pop 40 Pop 20


Pop 30 Pop 10 Pop
40 T 40 “Stack-
30 30 underflow”
T 30
20 20 20 T 20
10 10 10 10 T 10
Queue
 A queue is a data structure in which insertion operation is performed at one end called
REAR and delete operation is performed at another end called FRONT.
 Queue follows First-In-First-Out(FIFO) principle i.e., the element that is added first will be
deleted first.
 The process of adding items to queue is called INSERT operation or enqueue and
removal of items from the queue is called DELETE operation or dequeue.
 Examples of queue:

People standing in queue in People standing in queue in front of


front of ATM machine billing counter
Queue Operations
INSERT operation(using List): # L-List Name, F-Front, R-Rear

Empty List L
L []

L 10 Insert 10 using- L.append(10)


F R
Insert 20 using- L.append(20)
L 10 20
F R
L 10 20 30 Insert 30 using- L.append(30)

F R
L 10 20 30 40 Insert 40 using- L.append(40)

F R

L 10 20 30 40 50 Insert 50 using- L.append(50)

F R
Queue Operations Cont…
DELETE operation(using List): # L-List Name, F-Front, R-Rear

L 10 20 30 40 50
F R Delete 10 using- L.pop(0)

L 20 30 40 50
F R Delete 20 using- L.pop(0)

L 30 40 50

F R Delete 30 using- L.pop(0)

L 40 50
F R Delete 40 using- L.pop(0)

L 50
F R Delete 50 using- L.pop(0)

L[ ] Empty List

You might also like