Member-only story

Deque, Priority Queue, and Master Theorem

Not all queues follow a First Come First Serve!

Mayur Jain
4 min readJan 27, 2021

In the previous blog post, we discussed Stack, Queue, and Heap and in continuation with that, we’ll discuss variants of Queue and how heap acts as the best data structure for performing priority queue and get to know a brief about what is master theorem & why it's used.

Deque

Deque is also known as a Double-Ended Queue. In the traditional queue, we perform insertion on the rear side and deletion on the front side of the queue following FIFO (First In First Out), in Deque, we can perform both insertion and deletion on both sides of the queue.

Figure 2: Deque

Various operations in Deque

  • Inserting at the front of the queue
  • Deletion from the front of the queue
  • Inserting at the rear of the queue
  • Deletion from the rear of the queue
  • IsEmpty
  • isFull

Simple Implementation of Deque using List

#Deque implementaion in python

class…

--

--

No responses yet