SVKM'S Nmimsuniversity Mukeshpatelschool of Technology Management & Engineering

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 10

SVKM’s NMIMSUniversity

MukeshPatelSchool of Technology Management & Engineering

PROGRAMME: MBATech (IT) SEMESTER III

COURSE: Data Structures and Algorithms Practical Experiment: 6

Part A (To be referred by students)

Circular Queue Implementation using Array


SAVE THE FILE AND UPLOAD AS (RollNo_Name_Exp6)

Topic covered:Circular QueueImplementation using Array


Learning Objective: Learner would be able to
1. Analyze the scenario to infer if queue data structure is appropriate.
2. Infer the features ofCircular Queue data structure.
3. Evaluate the working of the algorithm for Circular Queue implementation using
arrays.
Theory:
 Why Circular Queue?
 Applications of Circular Queue

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

PROGRAMME: MBATech (IT) SEMESTER III

COURSE: Data Structures and Algorithms Practical Experiment: 6

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) tempQ[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

PROGRAMME: MBATech (IT) SEMESTER III

COURSE: Data Structures and Algorithms Practical Experiment: 6

Part B (to be completed by students)

(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)

Roll No.: I068 Name: Harshita Rathore


Prog/Yr/Sem: MBA Tech IT / 2nd year / 3 Batch: A3
Date of Experiment: 10-09-2021 Date of Submission: 14-09-2021

1. Questions based on Experiment Scenario:


a. Explain the queue operations.
Queue operations may involve initializing or defining the queue, utilizing it, and then
completely erasing it from the memory. Here we shall try to understand the basic operations
associated with queues −
 enqueue() − add (store) an item to the queue.
 dequeue() − remove (access) an item from the queue.
Few more functions are required to make the above-mentioned queue operation efficient.
These are −
 peek() − Gets the element at the front of the queue without removing it.
 isfull() − Checks if the queue is full.
 isempty() − Checks if the queue is empty.

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:

1. Computer controlled Traffic Signal System uses circular queue.


2. CPU scheduling and Memory management.

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

PROGRAMME: MBATech (IT) SEMESTER III

COURSE: Data Structures and Algorithms Practical Experiment: 6

4|Page
SVKM’s NMIMSUniversity
MukeshPatelSchool of Technology Management & Engineering

PROGRAMME: MBATech (IT) SEMESTER III

COURSE: Data Structures and Algorithms Practical Experiment: 6

5|Page
SVKM’s NMIMSUniversity
MukeshPatelSchool of Technology Management & Engineering

PROGRAMME: MBATech (IT) SEMESTER III

COURSE: Data Structures and Algorithms Practical Experiment: 6

6|Page
SVKM’s NMIMSUniversity
MukeshPatelSchool of Technology Management & Engineering

PROGRAMME: MBATech (IT) SEMESTER III

COURSE: Data Structures and Algorithms Practical Experiment: 6

7|Page
SVKM’s NMIMSUniversity
MukeshPatelSchool of Technology Management & Engineering

PROGRAMME: MBATech (IT) SEMESTER III

COURSE: Data Structures and Algorithms Practical Experiment: 6

8|Page
SVKM’s NMIMSUniversity
MukeshPatelSchool of Technology Management & Engineering

PROGRAMME: MBATech (IT) SEMESTER III

COURSE: Data Structures and Algorithms Practical Experiment: 6

9|Page
SVKM’s NMIMSUniversity
MukeshPatelSchool of Technology Management & Engineering

PROGRAMME: MBATech (IT) SEMESTER III

COURSE: Data Structures and Algorithms Practical Experiment: 6

3. Conclusion (Learning Outcomes):Reflect on the questions answered by you jot down


your learnings about the Topic and Problem Statements based on the Topic.

WE HAVE SUCCESSFULLY LEARNT ABOUT CIRCULAR QUEUE, ITS CODE


AND ALGORITHM.

10 | P a g e

You might also like