XII Data Structure Reading Material
XII Data Structure Reading Material
Applications of Stack
Recursion
Postfix notations(Evaluation of expressions)
Tower of Hanoi
Insert operation: It means inserting element at the rear (or back) end of
the queue. This can be done using append() method of list as:
Q.append(element), where Q is a list.
Delete operation: It represents removing the element from the front of the
queue. This can be done using pop() method of list as: Q.pop(0), where Q
is a list.
Applications of Queue
CPU scheduling
Resource sharing
Multiprogramming
Real time system
Program to implement Queue using list
Program Output
Q=[] #to create empty list 1.Insert
def insertq(): 2.delete
n=int(input("Enter a number: ")) 3.display
Q.append(n) Enter your choice: 1
def deleteq(): Enter a number: 15
if Q==[]: 1.Insert
print("underflow") 2.delete
else: 3.display
print(Q.pop(0),"deleted”) Enter your choice: 1
def display(): Enter a number: 25
if Q==[]: 1.Insert
print("underflow") 2.delete
else: 3.display
for i in Q: Enter your choice: 1
print(i,end=' ') Enter a number: 35
print() 1.Insert
char=True 2.delete
while(char): 3.display
print("1.Insert") Enter your choice: 3
print("2.delete") 15 25 35
print("3.display") 1.Insert
ch=int(input("Enter your choice: ")) 2.delete
if ch==1: 3.display
insertq() Enter your choice: 2
elif ch==2: 15 deleted
deleteq() 1.Insert
elif ch==3: 2.delete
display() 3.display
else: Enter your choice: 3
char=False 25 35
1.Insert
2.delete
3.display
Enter your choice: 1
Enter a number: 45
1.Insert
2.delete
3.display
Enter your choice: 3
25 35 45
1.Insert
2.delete
3.display
Enter your choice: