Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 6

CLASS: XII SUBJECT: COMPUTER SCIENCE

UNIT: 1 LESSON: QUEUES No of session required: 1

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

SUBJECT: Computer Science Class & Sec: ____________ Topic: QUEUES

Name of the Student:______________________________________________ Roll No._______

1) Multiple Choice Questions


i) Data structure Queue is also known as …………………………………………….. list.
a) First In First Out b) First In Last Out c) Last In First Out d) All of these
ii) In a Queue, insertions takes place at ……………………………………………..… end.
a) Front b) top c) rear d) any
iii) In Queue, deletions take place at …………………………………………………….. end.
a) Front b) top c) rear d) any
iv) Insertion and Deletion operations in Queue are known as ………………………
a) Push and Pop b) Enqueue and Dequeue
c) Insert and Delete d) None

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

2) Fill in the Blanks


i) A queue is linear structure implemented in FIFO (………... ……..……. ……..…… …….…… ) manner.
ii) The Enqueue operation adds item at the ………………………. end of the queue.
iii) The Dequeue operation removes the item from the …………………………… end of the queue.
iv) Adding an element in a queue is called …………………….. operation.
v) ……………………….. refers to a situation (ERROR) when one tries to dequeue/delete an item from an empty
queue.

WORKSHEET: 2

SUBJECT: Computer Science Class & Sec: ____________ Topic: QUEUES

Name of the Student:______________________________________________ Roll No._______

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))

4 Write a function in python, MakePush(Information_Description,Information,size) to add a new Information and


MakePop(Information_Description) to delete a Information from a List of Information_Description, considering them to
act as push and pop operations of the Queue data structure.
SOLUTION:
def MakePush(Information_Description,Information,size):
if len(Information_Description)<limit:
Information_Description.append(Information)
else:
print(“Queue is Full!!!”)

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

SUBJECT: Computer Science Class & Sec: ____________ Topic: QUEUES

Name of the Student:______________________________________________ Roll No._______

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

3. A linear Queue called directory contains the following information:


- Pin code of city
- Name of city
Write the program to show add(directory) and delete(directory) methods in python.

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.

You might also like