Overview of Queue Data Structure 🤔🤓
class Queue(object):
def __init__(self):
self.items = []
def isEmpty(self):
return self.items == []
def enqueue(self, data):
return self.items.insert(0, data)
def dequeue(self):
return self.items.pop()
def size(self):
return len(self.items)
q = Queue()
print("Is Empty {}".format(q.isEmpty()))
q.enqueue(1)
q.enqueue(2)
q.enqueue(3)
print(q.dequeue())
print("Size {}".format(q.size()))
Recommended Reading:
How to start learning Python Programming 👈
Implementation of Stack in Python 👈
If you like my post please follow me to read my latest post on programming and technology.
A design pattern is a reusable solution to a commonly occurring problem in software design. They…
Factory Method is a creational design pattern that deals with the object creation. It separates…
You are given two singly linked lists that intersect at some node. Your task is…
A builder plans to construct N houses in a row, where each house can be…
Find the length of the longest absolute path to a file within the abstracted file…
You manage an e-commerce website and need to keep track of the last N order…