def main(): circular = CircularQueue(100000) bounded = BoundedQueue(100000) for i in range(100000): circular.enqueue(i) bounded.enqueue(i) start1 = time.time() while not circular.isEmpty(): circular.dequeue() end1 = time.time() circulartime = end1 - start1 start2 = time.time() while not bounded.isEmpty(): bounded.dequeue() end2 = time.time() boundedtime = end2 - start2 print('For Bounded Queue, the total runtime of dequeing 100000 is:\n' + str(boundedtime)) print('For Circular Queue, the total runtime of dequeing 100000 is:\n' + str(circulartime))
def main(): normalQueue = CircularQueue(3) vipQueue = CircularQueue(3) command = input("Add, Serve, or Exit: ") while (command != "Exit"): if command == "Add": name = input("Enter the name of the person to add: ") isVIP = input("Is the customer VIP? ") if isVIP == "True": if vipQueue.isFull(): print("Error: VIP customers queue is full") else: vipQueue.enqueue(name) statement = "add " + name + " to VIP line" print(statement) elif isVIP == "False": if normalQueue.isFull(): print("Error: Normal customers queue is full") else: normalQueue.enqueue(name) statement = "add " + name + " to the line" print(statement) else: print("Wrong Command. Please Enter True or False") #break #isVIP = input("Is the customer VIP? ") #? elif command == "Serve": if vipQueue.isEmpty() and normalQueue.isEmpty(): print("Error: Queues are empty") else: if not vipQueue.isEmpty(): served = vipQueue.dequeue() statement = served + " has been served" print(statement) else: served = normalQueue.dequeue() statement = served + " has been served" print(statement) else: print("Wrong Command. Please Enter Add, Serve or Exit") printQueues(normalQueue, vipQueue) command = input("Add, Serve, or Exit: ") print('Quiting')
def main(): normal = CircularQueue(3) vip = CircularQueue(3) Loop = True while Loop: choose = input("Add, Serve, or Exit: ") if choose == "add": names = input("Enter the name of the person to add: ") types = input("Is the customer VIP? ") if types == "True": if not vip.isFull(): vip.enqueue(names) print("add", names, "to VIP line.") else: print("Error: vip customer queue is full") elif types == "False": if not normal.isFull(): normal.enqueue(names) print("add", names, "to the line.") else: print("Error: Normal customer queue is full") else: print("invild name input") print("people in the line:", normal) print("VIP customers queue:", vip) Loop = True elif choose == "serve": if not vip.isEmpty(): print(vip.dequeue(), "has been served") else: if not normal.isEmpty(): normal.dequeue() else: print("Error: Queues are empty") print("people in the line:", normal) print("VIP customers queue:", vip) elif choose == "exit": print("Quitting") break else: Loop = True print("Invild input")