Skip to content

Coin row

planning ahead

Level 2 of 3

Also called Coin-row problem and Most money with no two neighbours, by dynamic programming.

fresh numbers

The test's questions that a run answers, asked again on new numbers whenever you like. The answer, its working and the reason for every other choice come from coin row's own run on the numbers shown.

choose one

question 1

How many comparisons does the method make on the row 6, 8, 7, 1, 3?

the answer, and why

the answer is B

4 to fill, one for each coin from the 2nd. Then the walk back makes 3, one for each coin it decides on, taking coins 5, 3, 1.

if you chose another

  • That is filling alone; the walk back compares too.
  • That is one for each coin, but filling skips coin 1 and the walk skips the coin before each one it takes.
  • That counts the walk visiting every coin, but each take skips the coin before it.

new numbersthe test page's numbers

question 2

Which row makes the method compare the most times?

the answer, and why

the answer is A

The method compares 10 times on 6, 3, 3, 5, 5, 3, 1, the most of the four.

if you chose another

  • On that row it compares 2 times, fewer than 10.
  • On that row it compares 3 times, fewer than 10.
  • On that row it compares 2 times, fewer than 10.

new numbersthe test page's numbers