Question: In this problem we describe a simple turn-based game. Let's suppose you're given an array, A, of n integers. Two players alternate removing 1,

In this problem we describe a simple turn-based game. Let's suppose you're

 

In this problem we describe a simple turn-based game. Let's suppose you're given an array, A, of n integers. Two players alternate removing 1, 2, or 3 numbers off of the end of the array. The game ends when the array is empty. A player's score is the sum of all of the numbers they have chosen. Suppose both players play optimally (i.e., try to win by the most points possible and, if winning is not possible, lose by the fewest points possible). Find the difference between the players scores at the end of the game (first player score - second player score). Array position i: 123456 7 8 9 Value at A[i]: 50 -60 5 30 25 -20 -100 -10 30 (1) (1 point) Example: For the array A given above, what would be the optimal scores of player 1 and player 2? Hint: the difference between the scores should be 140 (2) Let "S(k) first player score second player score" where 0 < k

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