0% found this document useful (0 votes)
150 views

Circular Queue in Data Structure

Circular queue is a linear data structure that follows the FIFO principle. Elements are added at the rear end and deleted at the front end of the queue, with the last node connected back to the first node to form a circle. This solves the re-buffering problem of standard queues by allowing elements to be inserted into the first empty space without having to reallocate the entire buffer. Elements can be inserted and deleted from a circular queue in constant O(1) time.
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
150 views

Circular Queue in Data Structure

Circular queue is a linear data structure that follows the FIFO principle. Elements are added at the rear end and deleted at the front end of the queue, with the last node connected back to the first node to form a circle. This solves the re-buffering problem of standard queues by allowing elements to be inserted into the first empty space without having to reallocate the entire buffer. Elements can be inserted and deleted from a circular queue in constant O(1) time.
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 2

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.

You might also like