Professional Documents
Culture Documents
CS-12-Data Structures (Queues)
CS-12-Data Structures (Queues)
Session Gist of Expected Learning Teaching Learning Suggested material / Assessment strategies Worksheets
Lesson Outcomes/ELO activities planned Resources planned/Assignments
1 Data Student will be able to Students are advised Students are advised MCQ Based
Structures: understand :- to see these videos to to watch video on worksheet
INTRODUCTION:
Lists as know Practical
covered in A new Data Demonstration Worksheet 1
Queue is a linear data
Class XI, Structure in Python more about Queues
structure that follows
Queues – - Queue https://youtu.be/
First In First Out (FIFO) https://youtu.be/
Insert, Concept of Queue rJwln2S2d1g CBSE Based
technique. JP2oW6EdUnQ
Delete using Implementation of Problem
a list Queue using List In Queues, insertion
takes place at rear end Study Material on Worksheet 2
Insertion of
and deletion takes place Mind Map Queues
elements in Queue
Deletion of from front end.
https:// Unsolved
elements in queue
https:// drive.google.com/ CBSE
Applications of
drive.google.com/ file/d/1I4o- Question
queues Watch this video for
file/d/ zQgxP3Gxp61JZPN
Introduction of Queue
1wDPmx4Ct48E7gih9 mf4EAUmTtw0iS Worksheet 3
https://youtu.be/ vuZVdhOw-3v2utyW
PYGmuZoHZlI
WORKSHEET: 1
v) ……………………………………………. form of access is used to add and remove nodes from a queue.
a) LIFO b) FIFO c) Both (a) and (b) d) None of these
vi) If a user tries to remove an element from empty queue, it is called ………………………
a) Underflow b) Empty collection c)Overflow d) Garbage Collection
WORKSHEET: 2
1. A particular Queue is being implemented as a list (named Books), where every element is again a list containing two
pieces of information – book_no and title. Write the functions Enqueue(Books) and Dequeue(Books) to add a new book
and to delete a book .
SOLUTION:
def Enqueue(Books):
bno = int(input(“Enter Book Number : ”))
title = input(“Enter Book Title: ”)
elem = [bno, title]
Books.append(elem)
def Dequeue(Books):
if Books==[]:
print(“Undeflow! Queue is empty”)
else:
elem = Books.pop(0)
print(“Popped Book : ”, elem)
2. A particular Queue is being implemented as a list (named Tickets), where every element is again a list containing two
pieces of information – ticket_id and name. Write the functions Queue(Tickets) and DeQueue(Tickets) to add a new
ticket and to delete a ticket considering them as insertion and deletion operations of the Queue data structure.
Note: Ask the user input in the Queue(Tickets) function itself.
SOLUTION:
def Queue(Tickets):
tid = int(input(“Enter Ticket ID : ”))
name = input(“Enter Name: ”)
elem = [tid, name]
Tickets.append(elem)
def DeQueue(Tickets):
if Tickets==[]:
print(“Undeflow! Queue is empty”)
else:
elem = Tickets.pop(0)
print(“Popped Ticket : ”, elem)
3. Write a function in Python, INSERTQ(QUEUE,data,limit) and DELETEQ(QUEUE) for performing insertion and deletion
operations in a Queue. QUEUE is the list used for implementing queue and data is the value to be inserted limit is the
maximum number of elements allowed in QUEUE at a time.
SOLUTION:
def INSERTQ(QUEUE,data,limit):
if len(QUEUE)<limit:
QUEUE.append(data)
else:
print(“Queue is Full!!!”)
def DELETEQ(QUEUE):
if len(QUEUE)==0:
print(“Queue is Empty!!!”)
else:
print(“deleted elemnt=”,QUEUE.pop(0))
def MakePop(Information_Description):
if len(Information_Description)==0:
print(“Queue is Empty!!!”)
else:
Information_Description.pop(0)
5. Write functions the insert and delete elements in Queue implemented using List.
SOLUTION:
defqins(Qu, item):
Qu.append(item)
if len (Qu)==1:
front=rear=0
else:
rear=len(Qu)-1
defqdel(Qu):
if len (Qu)==0:
return ‘Underflow’
else:
item=Qu.pop(0)
if len(Qu)==0:
front=rear=None
return item
WORKSHEET: 3
1. Write a function in Python, INSERTQ(Arr,data) and DELETEQ(Arr) for performing insertion and deletion operations in a
Queue. Arr is the list used for implementing queue and data is the value to be inserted.
2. Write a function in python, MakePush(Package) and MakePop(Package) to add a new Package and delete a Package from
a List of Package Description, considering them to act as push and pop operations of the Queue data structure
4. Write addclient(client) and deleteclient(client) method in python to add a new client and delete a client from a list client
name, considering them to act as insert and delete operation of the queue data structure.
5. Write the program that contains addscore(game) and delete(game) methods in python to show insertion and deletion
operation in a queue.