0% found this document useful (0 votes)
38 views2 pages

BC180203450 CS502-Fundamentals of Algorithms Assignment No 3

The document describes an activity selection problem where the goal is to identify a set of mutually exclusive activities using a greedy selection algorithm. It provides the start and end times of 12 activities in a table and describes a greedy algorithm that selects activities where the start time of the next activity is greater than the finish time of the previous one. By applying this algorithm to the given activities, it identifies the set of non-interfering activities as {a1 , a3 , a6 , a8 , a10 , a12 }.

Uploaded by

MH Amber
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
38 views2 pages

BC180203450 CS502-Fundamentals of Algorithms Assignment No 3

The document describes an activity selection problem where the goal is to identify a set of mutually exclusive activities using a greedy selection algorithm. It provides the start and end times of 12 activities in a table and describes a greedy algorithm that selects activities where the start time of the next activity is greater than the finish time of the previous one. By applying this algorithm to the given activities, it identifies the set of non-interfering activities as {a1 , a3 , a6 , a8 , a10 , a12 }.

Uploaded by

MH Amber
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

BC180203450

CS502- Fundamentals of Algorithms


Assignment no 3

Question: Activity selection problem.


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

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

To full fill the requirement of mutually exclusive greedy selection algorithm.


Our starting time of the next activity must be greater then the finishing time of the
previous activity.In our first activity the finishing time 3, so our next activity starting
time must be greater then the 3 that is 3th activity having starting time 4 which is
greater then the 3. So next activity are as follow, 6th ,8th 10th and 12th .

A = {a1 , a3 , a6 , a8 , a10 , a12 }

You might also like