Download as pdf or txt
Download as pdf or txt
You are on page 1of 2

Data Structures – Lab 10 12-03-2021

Note:
 This is a strictly individual work. Sharing the solution with each other will be considered as
violation of the honor code and any suspicious activity may be referred to the disciplinary
committee. In case of any help, please consult the instructor.
 You can’t use any built-in function to implement following tasks.
Submission Deadline: 3 December 2021, 12:50 PM.
Total Marks:

Exercises

1. Write a program to create a Queue of jobs/processes with following functionalities:


a. Delete_Job (): A job having the highest priority must be removed
from the queue.
b. Add_Job(): To add a job in the Queue.
c. Generate_job(): Create object of the class job with random values of the
attributes.
d. Print_Queue(): print all the attributes of all jobs present in the Queue. This
function should be called after every addition or deletion in/from the Queue.

A job has three attributes: ID, Burst time and Priority.

After every 3 seconds, call Add_job () or Delete_job (). Using random number, decide
whether Add-job () or Delete_job () is to be called.

Note: Value of the priority must be greater than 0. And if there are many jobs in the
Queue then the job with the lowest value of the attribute ‘priority’ should be removed

2. Write a function Is-Heap() which takes an array as input and returns true if the given
array represents a Min-Heap otherwise returns false.

3. Write a program to implement a Min-Heap using array. Following functions should be


part of the Heap:
a. Add_value (adds an element in the heap)
b. Delete_value (Remove minimum value from the heap)
c. Display-values (print all elements of the Heap (each level on a different line))
Data Structures – Lab 10 12-03-2021

4. Your program should display a menu of choices to operate the Min-Heap. See the
sample menu below:
a. Insert (add a value in the Min-Heap)
b. Delete (delete lowest value from the Min-Heap)
c. display (show all the values present in the Min-Heap)
if user enters ‘a’, take a value as input and add it in the heap and if ‘b’ is given as in-
put then delete the minimum value from the heap while on ‘c’, heap should be dis-
played.

You might also like