Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

the result of the top is:1398 but my result is :1369 my code: #include #include #include #include using namespace std; int jumplt(const int gameboard[],int n,int

image text in transcribed

the result of the top is:1398

but my result is :1369

my code:

#include #include #include #include using namespace std; int jumplt(const int gameboard[],int n,int size); int main() { int gameboard[9]; ifstream infile; infile.open("jump.txt"); if(infile.is_open()) { for (int i=0;i> gameboard[i]; cout

int jumplt(const int gameboard[],int n,int size) { if (size==n) return gameboard[n]; else if (size - 1 == n) return gameboard[0] + gameboard[size]; else if(jumplt(gameboard,n+1,size) 16. The game of "Jump It" consists of a board with n positive integers in a row, except for the first column, which always contains 0. These numbers rep- resent the cost to enter each column. Here is a sample game board where n is 6: 0 3 80 6 57 10 The object of the game is to move from the first column to the last column with the lowest total cost. The number in each column represents the cost to enter that column. You 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 columns visited. In the board shown above, there are several ways to get to the end. Starting in the first column, our cost so far is 0. We could jump to 80, then jump to 57, then move to 10 for a total cost of 80 +57 + 10 - 147. However, a cheaper path would be to move to 3, jump to 6, then jump to 10, for a total cost of 3 + 6 + 10 = 19. Write a recursive solution to this problem that computes the lowest cost of the game and outputs this value for an arbitrarily large game board represented as an array. Your program doesn't have to output the actual sequence of jumps, only the lowest cost of this sequence. After making sure that your solution works on small arrays, test it on boards of larger and larger values of n to get a feel for the scalability and efficiency of your solution. Example: FE) (O) MARIME 0 298 157 272 440 368 394 223 54 378 1 100% Unix (LF) UTF-8

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

Database 101

Authors: Guy Kawasaki

1st Edition

0938151525, 978-0938151524

Students also viewed these Databases questions

Question

What is the principle of thermodynamics? Explain with examples

Answered: 1 week ago

Question

What are the Five Phases of SDLC? Explain each briefly.

Answered: 1 week ago

Question

How can Change Control Procedures manage Project Creep?

Answered: 1 week ago