QUEUE IMPLEMENTATION
q=[]
print("\t\t\t QUEUE IMPLEMENTATION")
print("\t\t\t ********************")
size=int(input("Enter the size of queue:"))
def Enqueue():
if len(q)==size:
print("Queue is full!!!")
else:
element=input("Enter the added element:")
[Link](element)
print(element,"is added to the Queue!")
def dequeue():
if not q:
print("Queue is empty!!!")
else:
e=[Link](0)
print("element removed!!:",e)
def display():
print(q)
while True:
print("select the operation:\[Link] \[Link] \[Link] \[Link]")
choice=int(input("Enter your choice:"))
if choice==1:
Enqueue()
elif choice==2:
dequeue()
elif choice==3:
display()
elif choice==4:
break
else:
print("Invalid operation!!!")
OUTPUT:
QUEUE IMPLEMENTATION
*************************
Enter the size of queue:5
select the operation:
[Link]
[Link]
[Link]
[Link]
Enter your choice:1
Enter the added element:4
4 is added to the Queue!
Select the operation:
[Link]
[Link]
[Link]
[Link]
Enter your choice:1
Enter the added element:5
5 is added to the Queue!
Select the operation:
[Link]
[Link]
[Link]
[Link]
Enter your choice:1
Enter the added element:3
3 is added to the Queue!
Select the operation:
[Link]
[Link]
[Link]
[Link]
Enter your choice:1
Enter the added element:9
9 is added to the Queue!
Select the operation:
[Link]
[Link]
[Link]
[Link]
Enter your choice:1
Enter the added element:2
2 is added to the Queue!
Select the operation:
[Link]
[Link]
[Link]
[Link]
Enter your choice:3
['4', '5', '3', '9', '2']
Select the operation:
[Link]
[Link]
[Link]
[Link]
Enter your choice:2
element removed!!: 4
Select the operation:
[Link]
[Link]
[Link]
[Link]
Enter your choice:2
element removed!!: 5
Select the operation:
[Link]
[Link]
[Link]
[Link]
Enter your choice:2
element removed!!: 3
Select the operation:
[Link]
[Link]
[Link]
[Link]
Enter your choice:2
element removed!!: 9
Select the operation:
[Link]
[Link]
[Link]
[Link]
Enter your choice:3
['2']
Select the operation:
[Link]
[Link]
[Link]
[Link]
Enter your choice:2
element removed!!: 2
Select the operation:
[Link]
[Link]
[Link]
[Link]
Enter your choice:3
[]
Select the operation:
[Link]
[Link]
[Link]
[Link]
Enter your choice:2
Queue is empty!!!
Select the operation:
[Link]
[Link]
[Link]
[Link]
Enter your choice:4