Question: Problem 9 - 2 You live in a country with very high medical costs and anticipate undergoing a super - expensive medical treatment for the

Problem 9-2
You live in a country with very high medical costs and anticipate undergoing a super-expensive medical treatment for the time period [S,F). Luckily, as long as you have at least one job, you will have a cheap health insurance which will fully cover your expensive treatment. You are also
very smart, so you get n job offers, where the i-th job is for the period [si,fi), so that the union
of [si,fi) fully covers the desired interval [S,F). For simplicity, assume the jobs are already sorted
by their starting times, so that s1s2dotssn.
Of course, one possible solution is to take all the jobs (it's OK to have multiple jobs at the same
time). However, being a naturally lazy person, you would like to take the smallest number of jobs which would cover the desired interval [S,F).
(a)(5 points) Design an efficient O(n) greedy algorithm for this problem. For partial credit, give O(n2) algorithm. (You will prove correctness in the next part.)
(b)(5 points) Prove the correctness of your algorithm using a local-swap argument.
(c)(4 points) Assume you can hold at most two jobs at the same time (e.g., each job only has a day shift and a night shift, and you have to be at the job). Does your solution from part (a) still work in this case? If yes, prove it. Else, give a counter-example.
Problem 9 - 2 You live in a country with very

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Accounting Questions!