Question: 3. Prove that if any algorithm A2 faster than yours exists, there will be some instance of this problem where A2 looses. write pseudo code

 3. Prove that if any algorithm A2 faster than yours exists,

3. Prove that if any algorithm A2 faster than yours exists, there will be some instance of this problem where A2 looses.

write pseudo code of java

Sometimes, brute force is the best we can do. Consider the following prob- lem: You live in a building of n floors. Someone keeps throwing eggs out of a balcony on some unknown floor f. At each time slot, this person will throw an egg. At each time slot, you can go to a balcony on any floor and attempt to save the egg. If the balcony you chose is below the thrower's, you save the egg. If, however, the balcony you chose is above the thrower's, the egg falls, breaks, and you lose the game. If the floor you chose is the same as the thrower's, you catch him and you win, saving the next generation of eggs. 1. Write a brute-force algorithm that will always win in this game without losing any eggs in the minimum number of time-slots. The input to your algorithm should be the number of floors n, and the output should be an array X of n integers, one integer for each time-slot. The entry X [i] determines which floor your algorithm will go to, at time-slot i. 2. A more efficient algorithm would catch the thrower in fewer time-slots than yours. Argue that there should not be a more efficient algorithm. Sometimes, brute force is the best we can do. Consider the following prob- lem: You live in a building of n floors. Someone keeps throwing eggs out of a balcony on some unknown floor f. At each time slot, this person will throw an egg. At each time slot, you can go to a balcony on any floor and attempt to save the egg. If the balcony you chose is below the thrower's, you save the egg. If, however, the balcony you chose is above the thrower's, the egg falls, breaks, and you lose the game. If the floor you chose is the same as the thrower's, you catch him and you win, saving the next generation of eggs. 1. Write a brute-force algorithm that will always win in this game without losing any eggs in the minimum number of time-slots. The input to your algorithm should be the number of floors n, and the output should be an array X of n integers, one integer for each time-slot. The entry X [i] determines which floor your algorithm will go to, at time-slot i. 2. A more efficient algorithm would catch the thrower in fewer time-slots than yours. Argue that there should not be a more efficient algorithm

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 Databases Questions!