Write a program to implement dequeue

Related Articles

The prominent applications of doubly ended queue are:. It can be used to implement both conventional stack and queue because of its property of insertion and deletion from both boardmaker book report. In the real world it is used to implement A-steal job scheduling algorithm.

In the below code we have four prominent functions.

Help Others, Please Share

We have 3 cases here:. Case 1 : If the array is empty, then we insert the element in the start i.

write a program to implement dequeue

Case 2 : If the front pointer is at first location i. Case 3 : If the above two cases are not true, then we simply decrement the prorgam pointer and insert the.

write a program to implement dequeue

Case 2 : If the rear pointer is at last location i. Case 3 : Top school dissertation hypothesis assistance the above two cases are not true, then we simply increment the rear pointer and insert the. We again have three cases:. Case 1 : If there is only one element, then we move both front and rear to Case 2 : If the front pointer is write a program to implement dequeue the last location i.

Case peogram : If the above two cases are not true, then we simply increment the front pointer.

Types of Deque

Case 2 : If the rear pointer is at the first location i. Case progrsm : If the above two cases are not true, then we simply decrement the rear pointer.

write a program to implement dequeue

I nserting element from rear: 2. Inserting element from rear: 7. The rear element is 7. Removing the rear element.

Learn Latest Tutorials

After removal,rear element is 2. Inserting element from front: 4.

write a program to implement dequeue

Inserting element from front: The front element is Removing the front element. After removal,front element is 4. It is also called head-tail linked list. Just like a regular queue, it is handled by two pointers i.]