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 03:00
Consider this data sequence: "3 11 5 5 5 2 4 6 6 7 3 -8". any value that is the same as the immediately preceding value is considered a consecutive duplicate. in this example, there are three such consecutive duplicates: the 2nd and 3rd 5s and the second 6. note that the last 3 is not a consecutive duplicate because it was preceded by a 7. write some code that uses a loop to read such a sequence of non-negative integers , terminated by a negative number. when the code finishes executing, the number of consecutive duplicates encountered is printed. in this case, 3 would be printed. assume the availability of a variable, stdin, that references a scanner object associated with standard input. that is, stdin = new scanner(system.in); is given.
Answers: 1
question
Computers and Technology, 22.06.2019 18:30
The "instance" relationship shows that something is an object of a
Answers: 1
question
Computers and Technology, 22.06.2019 19:30
When creating a presentation in libre office impress, where does the editing of slides take place?
Answers: 1
question
Computers and Technology, 23.06.2019 02:00
Which software would you use to create a print design? a. illustrator b. audacity c. reaper d. dreamweaver
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
English, 09.10.2020 22:01
Questions on the website: 13722361