Question: Coin - row problem: There is a row of n coins whose values are some positive integers c 1 , c 2 , dots, c

Coin-row problem: There is a row of n coins whose values are some positive integers c1,c2,dots,cn, not necessarily distinct. The
goal is to pick up the maximum amount of money subject to the constraint that no two coins adjacent in the initial row can be
picked up.
Solution: ALGORITHM CoinRow(C [1..n])
//Applies formula (8.3), p285 of the textbook, bottom up to find the maximum amount of money
//that can be picked up from a coin row without picking two adjacent coins
//Input: Array C[1..n] of positive integers indicating the coin values
//Output: The maximum amount of money that can be picked up
F[0]larr0;F[1]larrC[1]
for ilarr2 to n do
F[i]larrmax(C[i]+F[i-2],F[i-1]) return F[n]
Apply the algorithm to the coin row of denominations 8,7,9,10,6,6 by filling the following table:
 Coin-row problem: There is a row of n coins whose values

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