Double Ended Queue (Dequeue) in C

In this tutorial you will learn about double ended queue (dequeue) in C.

What is Dequeue? 

The word dequeue is short form of double ended queue. In a dequeue, insertion as well as deletion can be carried out either at the rear end or the front end.

Also Read: Circular Queue in C

Operations on a Dequeue

1. initialize(): Make the queue empty
2. empty(): Determine if queue is empty
3. full(): Determine if queue is full
4. enqueueF(): Insert an element at the front end of the queue
5. enqueueR(): Insert an element at the rear end of the queue
6. dequeueR(): Delete the rear element
7. dequeueF(): Delete the front element
8. print(): Print elements of the queue
 
Double Ended Queue (Dequeue) in C
 

Double Ended Queue (Dequeue) in C

A C program is given below which shows how various operations can be performed on a double ended queue represented by circular array.

 

Output
1.Create
2.Insert(rear)
3.Insert(front)
4.Delete(rear)
5.Delete(front)
6.Print
7.Exit

Enter your choice:1

Enter number of elements:3

Enter the data:4 6 7

1.Create
2.Insert(rear)
3.Insert(front)
4.Delete(rear)
5.Delete(front)
6.Print
7.Exit

Enter your choice:6

4
6
7

1.Create
2.Insert(rear)
3.Insert(front)
4.Delete(rear)
5.Delete(front)
6.Print
7.Exit

Enter your choice:4

Element deleted is 7

1.Create
2.Insert(rear)
3.Insert(front)
4.Delete(rear)
5.Delete(front)
6.Print
7.Exit

Enter your choice:7

Comment below if you found anything incorrect in above program for double ended queue (dequeue) in C.
Category: DSA

3 thoughts on “Double Ended Queue (Dequeue) in C

  1. Fede

    Hey man,
    I suggested to link also the stdlib library for the declaration of function exit.
    #include
    And you can use exit(EXIT_SUCCESS); instead of exit(0);

    Bye!

    Reply

Leave a Reply

Your email address will not be published. Required fields are marked *