In this Java tutorial, we are going to discuss the circular queue and its array implementation in java.
Circular Queue is a linear data structure in which operations are performed on FIFO ( First In First Out ) basis . Element at last position is connected to front element in circular queue .
In linear queue we can insert elements till the size of the queue is not fully occupied after that we cannot insert new element even if there is space in the front position.
In a circular queue if the queue becomes full and if there is a vacant position in front then the new element is added at the front. Items can be inserted and deleted from Queue in O(1) time.
1.) Front:- Get the front item from the queue.
2.) Rear:- Get the last item from the queue.
3.) enqueue(item):- This function is used to insert an element with value item in the queue.
4.) dequeue():- This function is used to remove an element from the front of the queue.
Circular Queue has application in CPU Scheduling , Memory management and in Traffic System .
« Digit Addition: How to add Digits of a given integer in Python?