subject

Consider a row of n coins of values v1, …, vn, where n is even. we play a game against an opponent by alternating turns. in each turn, a player selects either the first or last coin from the row, removes it from the row permanently, and receives the value of the coin. the goal is to maximize the total value of the coins collected. each player plays optimally.

1. give an example of a sequence of coins such that it is not optimal for the first player to start by picking the available coin of larger value. that is, the greedystrategy of always picking the larger coin is suboptimal. recall that n is even.

2. give an o(n2) dynamic programming algorithm to compute an optimal strategy for the first player. the first player should be able to make each move optimally in o(1) time. your algorithm should return the optimal strategy for the first player, not the final score.

3. define the subproblems you will use to solve this problem. define all variables you introduce.

4. write a recurrence expressing the optimal solution of the general subproblem in terms of optimal solutions of smaller subproblems. solve the base cases.

5. describe your algorithm in pseudocode. comment your code.

6. explain clearly and concisely why your algorithm is correct. restatements of steps of the algorithm will receive no credit.

7. analyze the running time of your algorithm, including the number of subproblems and the time spent per subproblem.

8. extend your algorithm to keep track of the optimal move at any point of the game.

ansver
Answers: 3

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 00:10
How does access indicates that a filter has been applied to a specific column
Answers: 1
question
Computers and Technology, 22.06.2019 15:10
David is in week 3 of his current ashford course and has a paper due by monday night at midnight. he has finished everything but the concluding paragraph. as he boots up his computer to work on it, he sees a flash across the screen and then the screen goes black. he begins to panic as he tries desperately to turn the laptop back on. david should have saved his work on what kind of portable device?
Answers: 2
question
Computers and Technology, 22.06.2019 21:30
After you clean an engine with hot water spray, it seems to stall; when it doesn't stall, it's idling noisily. technician a says to check for loose bolts on the flex plate near the torque converter. technician b says to wipe down the spark plug wires and the distributor cap. who is correct? a. technician a b. both technicians a and b c. technician b
Answers: 1
question
Computers and Technology, 24.06.2019 00:00
The gene form of a trait is called a(n) 
Answers: 2
You know the right answer?
Consider a row of n coins of values v1, …, vn, where n is even. we play a game against an opponent b...
Questions
question
Mathematics, 05.10.2019 13:50
Questions on the website: 13722367