0% found this document useful (0 votes)
91 views5 pages

Lab Exercise 6 Queues

1. The document provides instructions for students to implement a circular queue using arrays as part of an IT data structures course. It explains the concepts of queues and circular queues. 2. The experimental procedure describes how to insert and delete elements from a circular queue by manipulating the front and rear pointers and checking for overflow and underflow. 3. Students are asked to create a program to simulate a circular queue with sample menus and outputs provided. They must also answer questions to test their understanding of queue operations, differences between queues and deques, and linear versus circular queues.

Uploaded by

jocansino4496
Copyright
© © All Rights Reserved
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
Download as doc, pdf, or txt
0% found this document useful (0 votes)
91 views5 pages

Lab Exercise 6 Queues

1. The document provides instructions for students to implement a circular queue using arrays as part of an IT data structures course. It explains the concepts of queues and circular queues. 2. The experimental procedure describes how to insert and delete elements from a circular queue by manipulating the front and rear pointers and checking for overflow and underflow. 3. Students are asked to create a program to simulate a circular queue with sample menus and outputs provided. They must also answer questions to test their understanding of queue operations, differences between queues and deques, and linear versus circular queues.

Uploaded by

jocansino4496
Copyright
© © All Rights Reserved
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
Download as doc, pdf, or txt
Download as doc, pdf, or txt
You are on page 1/ 5

INFORMATION TECHNOLOGY EDUCATION DEPARTMENT

ITDSTRUCL
(DATA STRUCTURES AND ALGORITHM)

EXERCISE

6
IMPLEMENTING CIRCULAR QUEUE

<student name>
<date performed>
<date submitted>
<submitted to>

I. Objectives:
At the end of the experiment students must be able to:
Cognitive
a.) Understand the execute technique of queues.
.
Psychomotor:
a.) construct a program that simulates a circular queue.
b.) implement a circular queue using arrays
c.) compile and debug the error of the program
Affective
a.) appreciate the concept behind this experiment
II. BACKGROUND INFORMATION
A queue is logically a first in first out (FIFO or first come first serve) linear data structure. The
concept of queue can be understood by our real life problems. For example a customer come and
join in a queue to take the train ticket at the end (rear) and the ticket is issued from the front end
of queue. That is, the customer who arrived first will receive the ticket first. It means the
customers are serviced in the order in which they arrive at the service centre.
The basic operations that can be performed on queue are
1. Insert (or add) an element to the queue (push)
2. Delete (or remove) an element from a queue (pop)
Simulation of a circular queue:

III. EXPERIMENTAL PROCEDURE:


Let Q be the array of some specified size say SIZE
INSERTING AN ELEMENT INTO THE QUEUE
1. Initialize front=0 rear = 1
2. Input the value to be inserted and assign to variable data
3. If (rear >= SIZE)
(a) Display Queue overflow
(b) Exit
4. Else
(a) Rear = rear +1
5. Q[rear] = data
6. Exit
DELETING AN ELEMENT FROM QUEUE
1. If (rear< front)
(a) Front = 0, rear = 1
(b) Display The queue is empty
(c) Exit
2. Else
(a) Data = Q[front]
3. Front = front +1
4. Exit
*Based from the given algorithm, create a program for circular queue.
Here is a sample output:
Enter the size of the Queue: 8
Menu
1.
2.
3.
4.

Enqueue
Dequeue
Display Queue
Exit

Create user defined function for each operation


1. Enqueue
Insert the data to the queue if the queue is not full. Else, display Queue Overflow. Display the
new Queue, Front, and Rear.

Enter a number: 1
Queue: 1
Front: 1
Rear: 1

2. Dequeue
Remove the data in Front. Display the new Queue, Front, and Rear
Queue: 2 3 4 5

Front: 2
Rear: 5
3. Display Queue

Display the Queue, Front and Rear


Queue:

2 3 4 5

Front: 2
Rear: 5

IV. QUESTION AND ANSWER:


1. Write the insertion and deletion procedures in a queue.
______________________________________________________________________________
______________________________________________________________________________
______________________________________________________________________________
______________________________________________________________________________
2. What are the various queue operations? Explain.
______________________________________________________________________________
______________________________________________________________________________
______________________________________________________________________________
______________________________________________________________________________
3. Distinguish between Queues and Deques?
______________________________________________________________________________
______________________________________________________________________________
______________________________________________________________________________
______________________________________________________________________________
4. Differentiate a linear queue from a circular queue?
______________________________________________________________________________
______________________________________________________________________________
______________________________________________________________________________
______________________________________________________________________________
__________________________________________________________________________

V. REFLECTIONS:
______________________________________________________________________________
______________________________________________________________________________
______________________________________________________________________________
______________________________________________________________________________
______________________________________________________________________________
______________________________________________________________________________
__________________________________________________________________________

You might also like