Solution Found!

Consider the following game. A dealer produces a sequence s1 sn of cards, face up

Chapter 6, Problem 6.13

(choose chapter or problem)

Get Unlimited Answers
QUESTION:

Consider the following game. A dealer produces a sequence s1 sn of cards, face up, whereeach card si has a value vi. Then two players take turns picking a card from the sequence, butcan only pick the first or the last card of the (remaining) sequence. The goal is to collect cards oflargest total value. (For example, you can think of the cards as bills of different denominations.)Assume n is even.(a) Show a sequence of cards such that it is not optimal for the first player to start by pickingup the available card of larger value. That is, the natural greedy strategy is suboptimal.(b) Give an O(n2) algorithm to compute an optimal strategy for the first player. Given theinitial sequence, your algorithm should precompute in O(n2) time some information, andthen the first player should be able to make each move optimally in O(1) time by lookingup the precomputed information.

Questions & Answers

QUESTION:

Consider the following game. A dealer produces a sequence s1 sn of cards, face up, whereeach card si has a value vi. Then two players take turns picking a card from the sequence, butcan only pick the first or the last card of the (remaining) sequence. The goal is to collect cards oflargest total value. (For example, you can think of the cards as bills of different denominations.)Assume n is even.(a) Show a sequence of cards such that it is not optimal for the first player to start by pickingup the available card of larger value. That is, the natural greedy strategy is suboptimal.(b) Give an O(n2) algorithm to compute an optimal strategy for the first player. Given theinitial sequence, your algorithm should precompute in O(n2) time some information, andthen the first player should be able to make each move optimally in O(1) time by lookingup the precomputed information.

ANSWER:

Step 1 of 3

(a) Let's consider a sequence (3,5,1,2).

The available card at first is 3 then the second player grabs the next card 5 and will win.

If the first player picks the last card or rightmost card from the set, then the first player will get a chance to pick the card 5 and will win.

Hence, a greedy approach does not guarantee the optimal result to the first player.

Add to cart


Study Tools You Might Need

Not The Solution You Need? Search for Your Answer Here:

×

Login

Login or Sign up for access to all of our study tools and educational content!

Forgot password?
Register Now

×

Register

Sign up for access to all content on our site!

Or login if you already have an account

×

Reset password

If you have an active account we’ll send you an e-mail for password recovery

Or login if you have your password back