Skip to content
Related Articles
Open in App
Not now

Related Articles

Difference between Queue and Deque (Queue vs. Deque)

Improve Article
Save Article
  • Difficulty Level : Medium
  • Last Updated : 17 Aug, 2022
Improve Article
Save Article

Queue:

The queue is an abstract data type or linear data structure from which elements can be inserted at the rear(back) of the queue and elements can be deleted from the front(head) of the queue.

Queue Data structure

Queue Data structure

The operations allowed in the queue are:

  • insert an element at the rear
  • delete element from the front
  • get the last element
  • get the first element
  • check the size of the queue
  • check if the queue is empty or not

Deque:

The double-ended queue is an abstract data type that generalizes a queue from which elements can be inserted or deleted either from both front(head) or rear(tail) ends.

Deque Data structure

Deque Data structure

The operations allowed in deque are:

  • insert an element at the back
  • Insert an element at the front
  • delete the element at the back
  • delete the element from the front
  • get the last element
  • get the first element
  • check the size of the deque
  • check if the deque is empty or not

There are two types of deque:

  • Input restricted deque: An input restricted dequeue is a queue in which deletion can be done from both the ends but insertion from the front will not be allowed.                                                                                                                             
  • Output restricted deque: An output restricted dequeue is a queue in which insertion can be done from both the ends but deletion from the rear will not be allowed.

Difference between Queue and Deque:

S.no  

Queue

Deque

1. Elements can only be inserted at the end of the data structure. Elements can be inserted from both ends of the data structure.
2. Elements can only be removed from the front of the data structure. Elements can be removed from both ends of the data structure.
3. Queues are a specialized data structure that uses the FIFO approach i.e., First In First Out. Deque can be used to implement the functionalities of both Stack (LIFO approach i.e., Last In First Out) and Queue (FIFO approach i.e., First In First Out).
4. A queue can be implemented using Array or Linked List. Deque can be implemented using Circular Array or Doubly Linked List.
5. Queue elements cannot be accessed with the help of an iterator. Deque can be traversed using iterator.
My Personal Notes arrow_drop_up
Related Articles

Start Your Coding Journey Now!