Professional Documents
Culture Documents
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:
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.
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.
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=======================================
GOOD LUCK