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.
Given an integer A. Compute and return the square root of A. If A is…
Given a zero-based permutation nums (0-indexed), build an array ans of the same length where…
A heap is a specialized tree-based data structure that satisfies the heap property. It is…
What is the Lowest Common Ancestor? In a tree, the lowest common ancestor (LCA) of…
A Binary Search Tree (BST) is a type of binary tree that satisfies the following…