I am doing a practice question from Midterm Dynamic Programming
The Problem : Consider a row of n numbers a1, ..., an. The numbers are all positive, and n is even. We play a game against an opponent, alternating turns. In each turn, a player selects either the first or last number, removes it from the row, and collects that much money.
For example, if the numbers are 1,2,3,4 , a possible game may look like:
- Player A takes 4: row is 1,2,3.
- Player B takes 3: row is 1,2.
- Player A takes 1: row is 2.
- Player B takes 2, game over.
Both players ended with a total amount of 5. Note that A could have done better.
(2 pts) Show an example where the greedy algorithm fails to achieve the highest possible amount of money.
Here is the solution to the problem Greedy Sol
In the diagram, does anyone know where the 11, the root of the tree, is coming from? I thought it was the highest possible amount of money but that be 13 here (10 + 3).