Grokking the Engineering Manager Coding Interview

0% completed

Diving Deeper – Circular Queues and Deques

Now that we've got a solid understanding of Simple Queues, it's time to take the plunge and dive deeper into the world of Queues. In this module, we'll explore two other types of Queues – Circular Queues and Deques (Double Ended Queues).

Understanding Circular Queues

The Concept of a Circular Queue

In a Circular Queue, the last element points back to the first element making a circular link. We can visualize it as a circle where we remove elements from one end and add elements at the other end, and it goes on in a cycle.

.....

.....

.....

Like the course? Get enrolled and start learning!
Leopoldo Hernandez

Leopoldo Hernandez

· 2 years ago

We really need more examples of circular queues and dequeues.

Especially with these data structures being implemented using linked lists rather than arrays.

T

tapasya234

· 6 months ago

The title suggests a deep dive into Circular Queues and Deques but it doesn't actually talk much about Deques. It has great content about Circular Queues and pitfalls about most queues in general but nothing about Deques.

V

Viktor

· 3 months ago

I believe this condition

} else if (rear == size - 1 && front != 0) { rear = 0; queue[rear] = element; }

is covered by the queue emptiness check:

if (front == (rear + 1) % size) { cout << "Queue is Full" << endl; }

so, the overall conditional can be simplified

Engin Yildirim

Engin Yildirim

· 2 years ago

We can do the following to check whether the queue is full or not when it is not empty:

if ((front == (rear + 1) % size)) { System.out.println("Queue is Full"); }

This condition unambiguously handles the wrap-around behaviour of the circular queue and ensures accurate detection of the full condition in all scenarios.

Show 1 reply
E

ethanedge

· 6 days ago

This is not a deep dive on Deques, the title should really be updated.