Problem

The residents of the underground city of Zion defend themselves through a combination of k...

The residents of the underground city of Zion defend themselves through a combination of kung fu, heavy artillery, and efficient algorithms. Re­cently they have become interested in automated methods that can help fend off attacks by swarms of robots.

Here's what one of these robot attacks looks like.

• A swarm of robots arrives over the course of n seconds; in the ith second, xi robots arrive. Based on remote sensing data, you know this sequence x1, x2, … ,xn in advance.

• You have at your disposal an electromagnetic pulse (EMP), which can destroy some of the robots as they arrive; the EMP's power depends on how long it's been allowed to charge up. To make this precise, there is a function f (•) so that if j seconds have passed since the EMP was last used, then it is capable of destroying up to f(j) robots.

• So specifically, if it is used in the kth second, and it has been j seconds since it was previously used, then it will destroy min(xk, f (j)) robots. (After this use, it will be completely drained.)

• We will also assume that the EMP starts off completely drained, so if it is used for the first time in the jth second, then it is capable of destroying up to f(j) robots.

The problem. Given the data on robot arrivals x1, x2, … ,xn, and given the recharging function f (•), choose the points in time at which you're going to activate the EMP so as to destroy as many robots as possible.

Example. Suppose n = 4, and the values of xt and f (i) are given by the following table.

i

1

2

3

4

xi

1

10

10

1

f (i)

1

2

4

8

The best solution would be to activate the EMP in the 3rd and the 4th seconds. In the 3rd second, the EMP has gotten to charge for 3 seconds, and so it destroys min(10,4) = 4 robots; In the 4th second, the EMP has only gotten to charge for 1 second since its last use, and it destroys min(1,1) = 1 robot. This is a total of 5.

(a) Show that the following algorithm does not correctly solve this problem, by giving an instance on which it does not return the correct answer.

In your example, say what the correct answer is and also what the algorithm above finds.

(b) Give an efficient algorithm that takes the data on robot arrivals x1, x2, … , xn, and the recharging function f (•), and returns the maximum number of robots that can be destroyed by a sequence of EMP activations.

Step-by-Step Solution

Request Professional Solution

Request Solution!

We need at least 10 more requests to produce the solution.

0 / 10 have requested this problem solution

The more requests, the faster the answer.

Request! (Login Required)


All students who have requested the solution will be notified once they are available.
Add your Solution
Textbook Solutions and Answers Search
Solutions For Problems in Chapter 6
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT