Tenzin N.

asked • 04/20/20

Recursion based problem

The game of "Jump it" consists of a board with positive integers in a row except for the first column, which always contains zero. These numbers represent the cost to enter each column. Here is a sample game board where is 6.


-------------------------

|0 | 3 | 80 | 6 | 59 | 10|

-------------------------


The object of the game is to move from the first column to the last column in the total lowest cost. The number in each column represents the cost to enter that column. Always start the game in the first column and have two types of moves. You can either move to the adjacent column OR jump over the adjacent column to land two columns over. The cost of a game is the sum of the costs of the visited columns. 

Write a recursive solution to this problem that calculates the cheapest possible cost and outputs this value, for an arbitrarily large game board represented as an array. Your program does not have to output the actual sequence of jumps, only the cheapest cost of this sequence. After making sure that your solution works on small arrays, test your solution on boards of larger and larger values of to get a feel for how efficient and scalable your solution is


1 Expert Answer

By:

Patrick B. answered • 04/21/20

Tutor
4.7 (31)

Math and computer tutor/teacher

Still looking for help? Get the right answer, fast.

Ask a question for free

Get a free answer to a quick problem.
Most questions answered within 4 hours.

OR

Find an Online Tutor Now

Choose an expert and meet online. No packages or subscriptions, pay only for the time you need.