Chapter 0: 13E (page 11)
Consider the following game. A “dealer” produces a sequence of “cards,” face up, where each card has a value . Then two players take turns picking a card from the sequence, but can only pick the first or the last card of the (remaining) sequence. The goal is to collect cards of largest total value. (For example, you can think of the cards as bills of different denominations.) Assume is even. (a) Show a sequence of cards such that it is not optimal for the first player to start by picking up the available card of larger value. That is, the natural greedy strategy is suboptimal. (b) Give an algorithm to compute an optimal strategy for the first player. Given the initial sequence, your algorithm should precompute in time some information, and then the first player should be able to make each move optimally in time by looking up the precomputed information.
Short Answer
- The sequence of cards is .
- we will provide an algorithm which give optimal solution.