8 - 9 Data Structure Stake Queue 1
8 - 9 Data Structure Stake Queue 1
NOIDA
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
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
Empty List L
L []
F R
L 10 20 30 40 Insert 40 using- L.append(40)
F R
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
L 40 50
F R Delete 40 using- L.pop(0)
L 50
F R Delete 50 using- L.pop(0)
L[ ] Empty List