Answered step by step
Verified Expert Solution
Question
1 Approved Answer
0) Consider a row of n coins of values v(1)... v(n), where n is even. We play a game against an opponent by alternating turns.
0) Consider a row of n coins of values v(1)... v(n), 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. Determine the maximum possible amount of money we can definitely win if we move first. Note: your opponent is intelligent as you are and he always takes the maximum option. Consider the following row of 4 coins: 39 2 1) Give an example of why the greedy algorithm of picking the max value in each turn is not optimal for you. 2) Formulating the DP recursive sub-problems Suppose we have coins lined up from Ci to C with the values of Vi to Vj respectively. Let Mr. j) = the maximum value a player can collect from i 'th coin to, 'th coin. Note that in every turn a player has two options: Either pick the ith coin (from starting) OR pick the jth coin (from the end) a. What is the recursive formula of MVi.j) for a player picking either coin i or j in every turn? Use your recursive formulas to solve the example given above of n-4. Note: Consider the cases when i =j and whenj = i + 1 which are both base cases. b. 3) What is the running time of your algorithm? 0) Consider a row of n coins of values v(1)... v(n), 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. Determine the maximum possible amount of money we can definitely win if we move first. Note: your opponent is intelligent as you are and he always takes the maximum option. Consider the following row of 4 coins: 39 2 1) Give an example of why the greedy algorithm of picking the max value in each turn is not optimal for you. 2) Formulating the DP recursive sub-problems Suppose we have coins lined up from Ci to C with the values of Vi to Vj respectively. Let Mr. j) = the maximum value a player can collect from i 'th coin to, 'th coin. Note that in every turn a player has two options: Either pick the ith coin (from starting) OR pick the jth coin (from the end) a. What is the recursive formula of MVi.j) for a player picking either coin i or j in every turn? Use your recursive formulas to solve the example given above of n-4. Note: Consider the cases when i =j and whenj = i + 1 which are both base cases. b. 3) What is the running time of your algorithm
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started