subject

The residents of the underground city of Zion defend themselves through a combination of kung fu, heavy artillery, and efficient algorithms. Recently they have become interested in automated methods that can help fend off attacks by swarms of robots. Here is what one of these robot attacks looks like.
• A swarm of robots arrives over the course of n seconds; in the i-th 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 has been allowed to charge up. To make it 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 k-th second, and it has been j seconds since it was previously used, then it destroys min(xk, f(j)) robots. (After this use, it will be completely drained.)
• We will also assume that EMP starts off completely drained, so if it is used for the first time in the j-th second, then it is capable of destroying up to f(j) robots.
The problem is: Given the data on robot arrivals x1, x2, . . . , xn, and given the recharging function f(·), choose the points in time at which you are going to activate the EMP so as to destroy as many robots as possible.
(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.
Schedule-EMP(x1, . . . , xn)
Let j be the smallest number for which f(j) ≥ xj
(If no such j exists then set j = n)
Activate the EMP in the j-th second
If n − j ≥ 1 then
Continue recursively on the input xj+1, . . . , xn
(i. e. invoke Schedule-EMP(xj+1, . . . , xn)
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, . . . , xn, and the recharging function f(·), and returns the maximum number of robots that can be destroyed by a sequence of EMP activations.

ansver
Answers: 2

Other questions on the subject: Computers and Technology

image
Computers and Technology, 22.06.2019 10:30, robert7248
You have a large, late-model pick-up truck with a rear seat. the pick-up truck weighs 6,500 pounds. the florida seat belt law
Answers: 1
image
Computers and Technology, 23.06.2019 06:00, tchloe448
What makes myhexadecimalnumber a child of mynumber? which methods does myhexadecimalnumber inherit directly from the mynumber class? what can an instance of the mynumber class do? what can an instance of the myhexadecimalnumber class do? which methods are overridden? why are they overridden? how many examples of overloading are there? why was this done? where is the super keyword used? what is it doing? why isn’t the incoming value set immediately in the second myhexadecimalnumber constructor? how many examples can you find of an inherited method being called?
Answers: 1
image
Computers and Technology, 23.06.2019 09:30, shadowsnake
Write a function called checkfactor that takes two arrays of positive numbers, firstnumberrow and secondnumberrow. checkfactor checks if the first entry in firstnumberrow is divisible by the first entry in secondnumberrow, and performs the same operation on the next array elements until all entries have been checked. all the numbers are positive and the number of entries in the arrays are the same. the function should return the identified divisible numbers in two row arrays named firstdivisible and seconddivisible. restrictions: branches or loops should not be used. the code must use the internal mod and logical functions. hint: the mod function should be used to determine if two numbers are divisible. ex: for num1 and num2 if mod(num1,num2) is 0, then the two numbers are divisible. this is matlab
Answers: 2
image
Computers and Technology, 23.06.2019 15:30, jasssp
Write a program in plp assembly that counts up by one starting from zero (or one) inside a loop and writes this value to the leds every time the value is increased. the memory address of the leds is 0xf0200000. the table below shows the meaning and an example usage of the instructions covered in the video, plp instructions for project 1. instruction example usage meaning load immediate li $t0, 8 register $t0 is set to the value, 8. store word sw $t2, 0($t1) the value in register $t1 is used as the memory address. the value in register $t2 is copied into this memory address. add addiu $t4, $t3, 29 register $t4 is assigned the sum of 29 and the value in register $t3. jump j your_label_name the program jumps to the line following the label, "your_label_name: ". label your label name: defines a label called "your_label_name: " that can be jumped to
Answers: 2
You know the right answer?
The residents of the underground city of Zion defend themselves through a combination of kung fu, he...

Questions in other subjects:

Konu
Mathematics, 23.11.2020 19:20