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.
Problem Statement: Given n pairs of parentheses, write a function to generate all combinations of well-formed parentheses. Example…
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…