COSC 2306 - First-In, First-Out (FIFO) Data Structure Visualizer
Items join at the Rear and leave from the Front. Think of a checkout line at a store—the first person in line is the first person served.
Implement a basic Queue class in Python using a list. Your implementation should include the standard operations.
enqueue(item)
Adds an item to the end of the queue.
dequeue()
Removes and returns the item at the
front.
isEmpty()
Returns True if the queue has no items.
size()
Returns the number of items in the queue.
Python implementation of a basic Queue:
class Queue:
def __init__(self):
self.items = []
def isEmpty(self):
return self.items == []
def enqueue(self, item):
self.items.append(item)
def dequeue(self):
if self.isEmpty():
return None
return self.items.pop(0)
def size(self):
return len(self.items)