Double ended queue ( deque ) using Arrays

In this module, we will cover

  • What's the core idea behind the double-ended queue ( deque )
  • Fundamental operations of the deque
  • Array implementation of deque in c++
  • Explanation of code

A double-ended queue is a queue where insertion and deletion can be performed at both ends.


Double-ended queue implements FIFO( First In First Out), LILO( Last In Last Out), FILO( First In Last Out), LIFO( Last In First Out).

  • An input restricted deque is one where deletion can be performed on both ends, but insertion can be made at one end only.
  • An output restricted deque is one where insertion can be performed on both ends, but deletion can be made at one end only.

Array implementation of the deque

Fundamental operations:

  1. insertFront( x ) : inserts the element ' x ' at the front end of the queue.
  2. insertRear( x ) : inserts the element ' x ' at the rear end of the queue.
  3. deleteFront( ) : deletes the front element of the queue.
  4. deleteRear( ) : deletes the rear element of the queue.
  5. frontElement( ) : returns the front element of the queue.
  6. rearElement( ) : returns the rear element of the queue.
  7. isEmpty( ) : checks whether the queue is empty or not.
  8. isFull( ) : checks whether the queue is full or not.
  9. size( ) : returns the size of the queue.

Code :


Explanation of code :



Any doubts regarding the above-discussed topic can be mentioned in the comment section and
we will cover the circular queue in the upcoming modules

Thank You

Comments