Posts

Showing posts with the label circular queue

Circular Queue Data Structure - The Coding Shala

Home >> Data Structures >> Circular Queue Circular Queue Data Structure In this post, you will learn what is Circular Queue in Data Structure and how to implement a circular queue in Java using an array. The circular queue is a linear data structure in which the operations are performed based on FIFO(first in First Out) principle and the last position is connected back to the first position to make a circle. It is also called the Ring Buffer. Why we need a Circular Queue? We know that in the simple queue if we remove an element from the head and we are not going to use that space again so it will be a complete waste. To prevent this we used a circular queue. For a circular queue, we may use a fixed-sized array and two pointers to indicate the starting position and the ending position. Circular Queue Java Program The following Java program explains the Circular queue. Here, i have implemented circular queue using an array. Java Program:  ...