4. (20 points) For the following problem, give an optimal greedy strategy. Prove that it is optimal by any technique, gi
-
answerhappygod
- Site Admin
- Posts: 899604
- Joined: Mon Aug 02, 2021 8:13 am
4. (20 points) For the following problem, give an optimal greedy strategy. Prove that it is optimal by any technique, gi
4. (20 points) For the following problem, give an optimal greedy strategy. Prove that it is optimal by any technique, give an algorithm implementing it, and give a time analysis for your algorithm. You have n real numbers x1 < x2 < x3 <...< xn and an integer k. You want to find k intervals [Si, Fi] so that they cover the numbers (each xj is in one of the intervals, i.e. Si sxj s Fi) in a way that minimizes the total length of intervals used, i.e., minimizes P 1sisk Fi -Si. For example if k = 3 and the numbers are 1, 3, 7, 12, 19, 23, 27, we could cover them with [1, 7], [12, 12], [19, 27] for a total length of 6 + 0 + 8 = 14. a.
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!