Professional Documents
Culture Documents
SVKM'S Nmimsuniversity Mukeshpatelschool of Technology Management & Engineering
SVKM'S Nmimsuniversity Mukeshpatelschool of Technology Management & Engineering
SVKM'S Nmimsuniversity Mukeshpatelschool of Technology Management & Engineering
Problem Statement:
1. Write a Menu driven Program to implement Circular QueueADT using array
Main queue operations:
a. enqueue(int): inserts an element at the end of the queue
b. int dequeue(): removes and returns the element at the front of the queue
Auxiliary queue operations:
c. int front(): returns the element at the front without removing it
d. int size(): returns the number of elements stored
e. int isEmpty(): indicates whether no elements are stored
1|Page
SVKM’s NMIMSUniversity
MukeshPatelSchool of Technology Management & Engineering
Step 1: IF FRONT=0 and REAR=MAX–1, or REAR = FRONT – 1 then Step 1: IF FRONT = -1, then
Write “OVERFLOW” Write “Underflow”
Goto Step 4 Goto Step 4
[END OF IF] [END OF IF]
Step 2: SET VAL = QUEUE[FRONT]
Step 2: IF FRONT = -1 and REAR = -1, then; Step 3: IF FRONT = REAR
SET FRONT = REAR = 0 SET FRONT = REAR = -1
ELSE IF REAR = MAX – 1 and FRONT! = 0 ELSE
SET REAR = 0 IF FRONT = MAX -1
ELSE SET FRONT = 0
SET REAR = REAR + 1 ELSE
[END OF IF] SET FRONT = FRONT + 1
Step 3: SET QUEUE[REAR] = VAL [END OF IF]
Step 4: Exit [END OF IF]
Step 4: EXIT
2. Write a Menu driven Program to implement Circular Queue ADT using array
Main queue operations:
a. enqueue(int): inserts an element at the end of the queue
b. int dequeue(): removes and returns the element at the front of the queue
Auxiliary queue operations:
c. int front(): returns the element at the front without removing it
d. int size(): returns the number of elements stored
e. int isEmpty(): indicates whether no elements are stored
Algorithmsize() Algorithmdequeue()
return (N - f + r) mod N ifisEmpty() then
Queue Empty
AlgorithmisEmpty() else
return (f == r) tempQ[f]
Q[f] null
Algorithmenqueue(int o) f (f + 1) mod N
ifsize() = Nthen returntemp
Queue Full
else Algorithm front()
Q[r] o ifisEmpty() then
r (r + 1) mod N Queue Empty
returnQ[f]
2|Page
SVKM’s NMIMSUniversity
MukeshPatelSchool of Technology Management & Engineering
(Students must submit the soft copy as per the following segments. Asoft copy containing
PartA and Part B answered must be uploaded on the platform specified by the Practical
Teacher. The filename should be RollNo_Name_Exp6)
b. Write in your own words two real-life scenarios where queue data structure is apt.
Below we have some common real-world examples where circular queues are used:
2. Program Code along with Sample Output: (Paste your program, input and output screen
shot for Program)
3|Page
SVKM’s NMIMSUniversity
MukeshPatelSchool of Technology Management & Engineering
4|Page
SVKM’s NMIMSUniversity
MukeshPatelSchool of Technology Management & Engineering
5|Page
SVKM’s NMIMSUniversity
MukeshPatelSchool of Technology Management & Engineering
6|Page
SVKM’s NMIMSUniversity
MukeshPatelSchool of Technology Management & Engineering
7|Page
SVKM’s NMIMSUniversity
MukeshPatelSchool of Technology Management & Engineering
8|Page
SVKM’s NMIMSUniversity
MukeshPatelSchool of Technology Management & Engineering
9|Page
SVKM’s NMIMSUniversity
MukeshPatelSchool of Technology Management & Engineering
10 | P a g e