Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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:
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

The Option Trader Handbook

Authors: George Jabbour

2nd Edition

0470481617, 978-0470481615

More Books

Students also viewed these Finance questions