You are on page 1of 2

Assignment No.

03
Total Marks: 20
SEMESTER Spring 2019
CS502- Fundamentals of Algorithms Due Date: 17/07/2019
Instructions
Please read the following instructions carefully before solving & submitting assignment:
It should be clear that your assignment will not get any credit if:
 The assignment is submitted after due date.
 The submitted assignment does not open or file corrupt.
 The assignment is full or partially copied from (other student or ditto copy from handouts or internet).
 Student ID is not mentioned in the assignment File or name of file is other than student ID.
 The assignment is not submitted in .doc or .docx format.

Uploading instructions
Your submission must include:

 Assignment should be in .doc or .docx format.


 Save your assignment with your ID (e.g. bx180200786.doc).
Assignment submission through email is NOT acceptable

Objective
The objective of this assignment is
 To give basic knowledge and understanding of Algorithms.
 To be able to understand and calculate the Activity selection problem using algorithms.
 To be able to understand the choice that seems to be the best at that moment.

Note:
Your answer must follow the below given specifications.
 Font style: “Times New Roman”
 Font color: “Black”
 Font size: “12”
 Bold for heading only.
 Font in Italic is not allowed at all.
 No formatting or bullets are allowed to use.
 Your answer should be precise and to the point, avoid irrelevant detail.

Lectures Covered: This assignment covers Lecture # 23 - 26


Deadline
Your assignment must be uploaded/submitted at or before 17/07/2019.
Question: Activity selection problem. (Marks: 20)

You have given a set of activities namely a1, a2, a3……….an along with its starting and ending time respectively. In
light of the information given below in the table form, you are required to identify (select) mutually exclusive (non-
interfering) set of activities using the given Greedy selection algorithm.

Set of activities: {a1, a2, a3………..an}


Start Time :{s1, s2, s3……………...sn}
Finish Time :{f1, f2, f3…………….fn}

Note: In this case n = 12

Activity Table:

ai 1 2 3 4 5 6 7 8 9 10 11 12
si 1 2 4 1 6 8 9 11 13 15 17 20
fi 3 5 7 8 9 10 11 14 16 18 20 24

Greedy: Activity-selector(s, f)

1. Begin
2. n=s.length
3. A [a1]
4. k 1
5. for m 2 to n
6. If s(m)>f (k)
7. A A U {am}
8. k m
9. Return A
10. End

=====================================Ended=======================================

For any query about the assignment, contact at CS502@vu.edu.pk

GOOD LUCK

You might also like