Queue 1
Queue 1
1.INTRODUCTION
❖TYPES OF QUEUE:
1.CIRCULAR QUEUE
2.DEQUEUE
3.PRORITY QUEUE
3. OPERATIONS ON QUEUE
❑Overflow occurs when the queue is full and there is no space for a new
element.
The array implementation of circular queue is similar to the array implementation of queue. The only
difference is that as soon as the rear index of the queue reaches the maximum size of the array, Rear is
reset to the beginning of the queue provided it is free. The circular queue is full only when all the locations
in the array are occupied.The circular queue is shown in Figure 4.3.
Various States of Circular Queue After insert and Delete
operations
Number of Elements in Circular Queue
The total number of elements in a circular queue at any point of time
can be calculated from the current values of the Rear and the Front
indices of the queue.
In case, Front<Rear, the total number of elements = Rear-Front+1. For
instance, in Figure 4.5(a), Front=3 and Rear=7.
Hence, the total number of elements in CQueue at this point of time is
7-3+1=5.
In case, Front>Rear, the total number of elements = Max+ (Rear-
Front) +1. For instance, in Figure 4.5(b), Front=3 and Rear=0. Hence,
the total number of elements in CQueue is 8+(0-3)+l.
Algorithm of Circular Queue
Algorithm of Circular Queue
6.PRIORITY QUEUE
A priority queue is a type of queue in which each element is assigned a
priority and the elements are added or removed according to that
priority. While implementing a priority queue, following two rules are
applied.