![]() ![]() As we have already seen that in linear queue, the memory is not managed very efficiently. Memory management: The circular queue provides memory management.The circular Queue can be used in the following scenarios: The deletion in a Queue always takes place from the front end. deQueue(): This function deletes an element from the Queue.The new element is always inserted from the rear end. enQueue(value): This function is used to insert the new value in the Queue.Rear: It is used to get the rear element from the Queue.Front: It is used to get the front element from the Queue.The following are the operations that can be performed on a circular queue: What is a Circular Queue?Ī circular queue is similar to a linear queue as it is also based on the FIFO (First In First Out) principle except that the last position is connected to the first position in a circular queue that forms a circle. The efficient approach to avoid the wastage of the memory is to use the circular queue data structure. It is not a practically good approach because shifting all the elements will consume lots of time. There is one solution to avoid such wastage of memory space by shifting both the elements at the left and adjust the front and rear end accordingly. ![]() The rear is at the last position of the Queue if we try to insert the element then it will show that there are no empty spaces in the Queue. In the above array, there are only two elements and other three positions are empty. So, to overcome such limitations, the concept of the circular queue was introduced.Īs we can see in the above image, the rear is at the last position of the Queue and front is pointing somewhere rather than the 0 th position. ![]() If the rear reaches to the end position of the Queue then there might be possibility that some vacant spaces are left in the beginning which cannot be utilized. There was one limitation in the array implementation of Queue. Next → ← prev Circular Queue Why was the concept of the circular queue introduced? ![]()
0 Comments
Leave a Reply. |