Unit II Linear Data Structures
Unit II Linear Data Structures
TYPES OF QUEUES-
CIRCULAR QUEUE
PRIORITY QUEUE
Why?
• Implementation of a linear queue brings the drawback of
memory wastage
• However, memory is a crucial resource that you should always
protect by analyzing all the implications while designing
algorithms or solutions.
• In the case of a linear queue, when the rear pointer reaches the
MaxSize of a queue, there might be a possibility that after a
certain number of dequeue() operations, it will create an empty
space at the start of a queue.
• Additionally, this newly created empty space can never be re-
utilized as the rear pointer reaches the end of a queue. Hence,
experts introduced the concept of the circular queue to
overcome this limitation.
• As shown in the figure,
the rear pointer arrives at the beginning
of a queue with the help of a circular
link to re-utilize the empty space to
insert a new element.
• This simple addition of a circular
link resolves the problem of memory
wastage in the case of queue implementation. Thus, this
particular type of queue is considered the best version of a queue
data structure.
What is Circular Queue in a Data Structure?