Problem Solving with C++ (9th Edition)
Problem Solving with C++ (9th Edition)
9th Edition
ISBN: 9780133591743
Author: Walter Savitch
Publisher: PEARSON
bartleby

Concept explainers

bartleby

Videos

Textbook Question
Book Icon
Chapter 14, Problem 6PP

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 represent 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.

Blurred answer
Students have asked these similar questions
AGU Computer Engineering Department created a new mathematical game that can be played with two people. In this game, you are given a list of random integers. At each round, the first player takes two numbers from the list and calculates the sum of these numbers. Then, the second player takes two numbers and makes the same calculation. The higher one is going to take the round and increment the score by 1. At the end of the game, who has the better score will win the game. Here are the rules for the game: There are always an even number of items on the list There are two colors for the players: Green and Red Green starts the game At each round, green plays and then red plays The player takes the first and the last numbers The game can end Tie when the scores are the same. The game will end when there is no element to take from the list Your program will simulate the rounds and find out the winner, Green or Red or Tie. The input will be two lines. Input Format…
AGU Computer Engineering Department created a new mathematical game that can be played with two people. In this game, you are given a list of random integers. At each round, the first player takes two numbers from the list and calculates the sum of these numbers. Then, the second player takes two numbers and makes the same calculation. The higher one is going to take the round and increment the score by 1. At the end of the game, who has the better score will win the game. Here are the rules for the game: There are always an even number of items on the list There are two colors for the players: Green and Red Green starts the game At each round, green plays and then red plays The player takes the first and the last numbers The game can end Tie when the scores are the same. The game will end when there is no element to take from the list Your program on java will simulate the rounds and find out the winner, Green or Red or Tie. The input will be two lines. Input…
You are hired by a game design company and one of their most popular games is The Journey. The game has a ton of quests, and for a player to win, the player must finish all the quests. There are a total of N quests in the game. Here is how the game works: the player can arbitrarily pick one of the N quests to start from. Once the player completes a quest, they unlock some other quests. The player can then choose one of the unlocked quests and complete it, and so on. For instance, let’s say that this game had only 4 quests: A, B, C, and D. Let’s say that after you complete • quest A, you unlock quests [B, D]. • quest B, you unlock quests [C, D]. • quest C, you unlock nothing [ ]. • quest D, you unlock quest [C]. Is this game winnable? Yes, because of the following scenario: The player picks quest A to start with. At the end of the quest A, the unlocked list contains [B, D]. Say that player chooses to do quest B, then the…

Additional Engineering Textbook Solutions

Find more solutions based on key concepts
When a class member is declared as protected, what code may access it?

Starting Out with Java: From Control Structures through Data Structures (3rd Edition)

The ____________ is always transparent.

Web Development and Design Foundations with HTML5 (9th Edition) (What's New in Computer Science)

What does a comparator do?

Digital Fundamentals (11th Edition)

Knowledge Booster
Background pattern image
Computer Science
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
SEE MORE QUESTIONS
Recommended textbooks for you
  • Text book image
    EBK JAVA PROGRAMMING
    Computer Science
    ISBN:9781337671385
    Author:FARRELL
    Publisher:CENGAGE LEARNING - CONSIGNMENT
Text book image
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781337671385
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT
Python Tutorial #10; Math Functions in Python; Author: Art of Engineer;https://www.youtube.com/watch?v=OviXsGf4qmY;License: Standard YouTube License, CC-BY