-
Notifications
You must be signed in to change notification settings - Fork 150
/
Copy pathQueue_Management_System.py
58 lines (52 loc) · 1.19 KB
/
Queue_Management_System.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
class Node:
def __init__(self, info):
self.info = info
self.next = None
def insert_item():
global front, rear
temp = Node(None)
item = int(input("\nEnter item to be inserted: "))
temp.info = item
temp.next = None
if front is None:
front = temp
else:
rear.next = temp
rear = temp
def del_item():
global front
if front is None:
print("\nQueue underflow")
else:
temp = front
print("\nElement after deletion is =", temp.info)
front = front.next
temp = None
def display():
global front
if front is None:
print("\nQueue is empty")
else:
print("\nContents of the queue are:")
trav = front
while trav is not None:
print(trav.info)
trav = trav.next
front = None
rear = None
while True:
print("\n1. Insert item")
print("2. Delete item")
print("3. Display")
print("4. Quit")
ch = int(input("\nEnter your choice: "))
if ch == 1:
insert_item()
elif ch == 2:
del_item()
elif ch == 3:
display()
elif ch == 4:
break
else:
print("\nWrong choice. Try again!")