Types of Deque

There are two variants of a double-ended queue. They include :

  • Input restricted queue
  • Output restricted queue

Input Restricted Queue

In Input restricted double ended queue, insertions can be done only at one of the end, while deletions can be done from both ends.

Input Restricted Deque

Output Restricted Queue

In output restricted double ended queue, deletions can be done only at one of the end, while  insertions can be done on both ends.

Output Restricted Queue

C implementation Double-Ended Queue

The double-ended queues, called deques for short, are a generalized form of the queue. It is exactly like a queue except that it does not follow the FIFO rule (First in first out) so, the elements can be added to or removed from either the front(head) or back(tail) of the deque.

In this article, we will learn about the double-ended queue implementation in C. We will also look at the working of the double-ended queue and the basic operations that can be performed using the double-ended queue in C.

Similar Reads

Double-Ended Queue Representation in C

In a deque we maintain two pointers front and rear, that point to either end of the deque. The elements in a deque extend from the front end to the rear end and since it is circular, dequeue[n–1] is followed by dequeue[0]....

Types of Deque

There are two variants of a double-ended queue. They include :...

Implementation of Double-Ended Queue in C

Dequeues can be implemented using two data structures....

Basic Operations on C Double-Ended Queue

We can perform the following basic operations in a double-ended queue:...

C Program to Implement Double-Ended Queue

The below program demonstrates all the major operations of a double-ended queue: insertion (at the front and at the rear), deletion (at the front and at the end), check empty and check full....

Applications of Deque

It can be used in job scheduling algorithm called A-Steal algorithm.It is be used for to store a software application’s list of undo operations.It can be used to implement both stack and queue.It can also be used to store the browsing history that includes recently visited URLs.It can be used in graph traversal BFS to store nodes and perform operations such as adding or removing nodes from both ends of the deque....

Advantages of Deque

It allows us to add and remove elements from both ends, hence providing more flexibility than a regular queue or stack.It can be used to implement both stacks and queues.It can efficiently provide the functionality of both LIFO and FIFO data structures.It is efficient as it takes O(1) time complexity to work with both ends.Deques are dynamic in size an d can grow and reduce in size dynamically.It is cache friendly as deque have cache-friendly contiguous subsequence....

Disadvantages of Deque

Deque is less memory efficient than a normal queue.It can cause synchronization issues multi-thread.It may not be supported by all platforms in such we need to implement it manually.It has limited functionality as compared to other data structures.Not suitable for sorting or searching, as these operations require linear time....

Frequently Asked Questions on Double-Ended Queue

What is a Deque in C?...

Contact Us