Professional Documents
Culture Documents
Theory:
1. Circular Queue:
Introduction
Why Circular Queue?
Applications
Algorithm Enqueue (x)
{
If IsFull( ) = = 1 then
{
Print “Queue is Full”
EXIT
}
else if IsEmpty( ) = = 1
front = rear = 0
else
rear = (rear + 1) mod N
CQ[rear] = x
}
Algorithm Dequeue()
{
if IsEmpty() = = 1
Print “Queue is Empty”
else if front = = rear
front = rear = -1
else
front = (front + 1) mod N
}
Algorithm IsFull()
{
If (rear+1) mod N = front
return 1
Else
return 0
}
Algorithm IsEmpty()
{
If front = = -1 and rear = = -1
return 1
else
return 0
}
Department of Information Technology
Algorithm front()
{
if IsEmpty() = = 1
Print “Queue is Empty”
else
print CQ[front]
}
Write a menu driven program with options: enqueue, dequeue, front, display.
Analyze the Performance of Circular Queue as an ADT with respect to time and
memory and state the Limitation of the approach.
Conclusion