Python | Queue using Doubly Linked List
A Queue is a collection of objects that are inserted and removed using First in First out Principle(FIFO). Insertion is done at the back(Rear) of the Queue and elements are accessed and deleted from first(Front) location in the queue.
1. enqueue() : Adds element to the back of Queue. 2. dequeue() : Removes and returns the first element from the queue. 3. first() : Returns the first element of the queue without removing it. 4. size() : returns the number of elements in the Queue. 5. isEmpty() : Return True if Queue is Empty else return False. 6. printqueue() : Print all elements of the Queue.
Below is the implementation of the above mentioned Queue operations using Doubly LinkedList in Python:
Queue operations using doubly linked list queue elements are: 4->5->6->7-> first element is 4 Size of the queue is 4 After applying dequeue() two times queue elements are: 6->7-> queue is empty: False
Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.
To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course. And to begin with your Machine Learning Journey, join the Machine Learning – Basic Level Course