Queues
A queue is a collection of elements that supports two main operations: enqueue (adds an element to the end of the queue) and dequeue (removes the front element from the queue).
python
# Create a queue using a list
queue = []
# Enqueue an element into the queue
queue.append(1)
# Dequeue an element from the queue
front_element = queue.pop(0)
No comments:
Post a Comment