Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Problem 3: A day at the beach. A group of n people are lying on the beach. The beach is represented by the real line
Problem 3: A day at the beach. A group of n people are lying on the beach. The beach is represented by the real line R and the location of the i-th person is some integer ; E Z. Your task is to prevent people from getting sunburned by covering them with umbrellas. Each umbrella corresponds to a closed interval I = [a, a + L] of length L E N, and the i-th person is covered by that umbrella if Xi E I. Design a greedy algorithm for covering all people with the minimum number of umbrellas. The input consists of the integers 21,.....In, and L. The output of your algorithm should be the positions of umbrellas. For example, if the input is x1 =1, 22 = 3, 23 = 5, and L = 2, then an optimum solution is the set of two umbrellas placed at positions 2 and 5, covering intervals (1,3] and [4,6]. 1 2 3 4 5 6 Prove that your algorithm is correct and that it runs in time polynomial in n
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