VOOZH about

URL: https://www.geeksforgeeks.org/dsa/deque-data-structure/

⇱ Introduction to Deque - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

Introduction to Deque

Last Updated : 5 Apr, 2026

A Deque (Double-Ended Queue) is a linear data structure that allows insertion and deletion of elements from both ends. Unlike a stack or a queue, where operations are restricted to one end, a deque provides flexibility to add or remove elements at the front as well as the rear.

  • Deque can act as both Stack and Queue
  • It is useful in many problems where we need to have a subset of all operations also like insert/remove at front and insert/remove at the end.
  • It is typically implemented either using a doubly linked list or circular array.
πŸ‘ Deque

Common Operations of Deque:

In order to make manipulations in a deque, there are certain operations provided to us.

  1. insertFront(x) β†’ Insert an element at the front end.
  2. insertRear(x) β†’ Insert an element at the rear end.
  3. deleteFront() β†’ Delete an element from the front end.
  4. deleteRear() β†’ Delete an element from the rear end.
  5. getFront() β†’ Retrieve (but don’t remove) the front element.
  6. getRear() β†’ Retrieve (but don’t remove) the rear element.
  7. isEmpty() β†’ Check if the deque is empty.
  8. size() β†’ Return the number of elements currently in the deque.

Code Example


Output
30 10 20 
10 

Implementation of Deque:

Deque can be implemented in Different Ways :-

Advantage of Deque:

πŸ‘ advantages_of_deque
Comment
Article Tags:
Article Tags: