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.
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…
You are given a stream of elements that is too large to fit into memory.…
The formula for the area of a circle is given by πr². Use the Monte…
Given an integer k and a string s, write a function to determine the length…
There is a staircase with N steps, and you can ascend either 1 step or…