Circular Queue in Data Structure
Circular Queue in Data Structure
Queue can be implemented as simple queue, queue and circular queue. Circular queue c is also implemented as same as simple queue, the main difference is that in circular queue last element will again points to first element In a standard queue data structure re-buffering problem occurs for each desuetude operation. To solve this problem b !oining the front and rear ends of a queue to ma"e the queue as a circular queue circular queue is a linear data structure. It follows FIFO Principle. # In circular queue the last node is connected bac" to the first node to ma"e a circle. # Circular lin"ed list fallow the $irst In $irst %ut principle # &lements are added at the rear end and the elements are deleted at front end of the queue # 'oth the front and the rear pointers points to the beginning of the arra . # It is also called as (ing buffer. # Items can inserted and deleted from a queue in %)*+time.
# If the front and rear are in ad!acent locations )i.e rear following front+ the message ,Queue is $ull , is displa ed. # If the value of front is -* then it denotes that the queue is empt and that the element to be added be the first element in the queue. The values of front and rear in such a case are set to and new element gets placed at -th position.
# .ome of the positions at the front end of the arra might be empt . This happens if we have deleted some elements from the queue. /hen the value of rear is 012-* and the value of front is greater than -. In such case value of rear is set to - and the element to be added is added to this position. # The element is added at the rear position in case the value of front is either equal to or greater than - and the value of rear is less than 012-*. Thus, if we add 3 elements the value of front and rear becomes - and 4 respectivel . The function displa )+ displa s the elements in the queue.