Question
Suppose n activities apply for using a common resource. Activity ai (1 i n) has a starting time S[i] and a finish time F[i] such
Suppose n activities apply for using a common resource. Activity ai (1 i n)
has a starting time S[i] and a finish time F[i] such that 0 < S[i] < F[i]. Two activities ai and aj (1
i, j n) are compatible if intervals [S[i], F[i]) and [S[j], F[j]) do not overlap. We assume the
activities have been sorted such that S [1] S [2] S[n].
(a) Design an O(n2) dynamic programming algorithm to find a set of compatible activities such
that the total amount of time the resource is used by these compatible activities is
maximized. You need to define the sub-problems, establish inductive formula, and show
the initial conditions. Pseudo code is not required.
(b) Apply your algorithm to the following set of activities
i 1 2 3 4 5 6 7 8 9 10 11 |
S[i] 2 3 5 6 7 9 10 12 13 14 16 |
F[i] 6 5 7 10 8 13 16 14 14 18 20 |
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started