Write a recursive solution to this problem that computes the shortest travel time of the game and display in the output. Your program does not have to output the actual sequence of moves, only the shortest travel time of this sequence.

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

PLZ help with the following:

In Java

 

Figure 2 and Figure 3 show the sample outputs.
>>>>>>Welcome to "FastestPath">>>>>>
For the following path:
0 5 90 7 61 12
The shortest time to the end is 24
>>>>>>>
Figure 2: Sample output
>>>>>»Welcome to "FastestPath">>>>>>
For the following path:
e 15 27 9 12 26 32
The shortest time to the end is 68
<<<<<<<
Transcribed Image Text:Figure 2 and Figure 3 show the sample outputs. >>>>>>Welcome to "FastestPath">>>>>> For the following path: 0 5 90 7 61 12 The shortest time to the end is 24 >>>>>>> Figure 2: Sample output >>>>>»Welcome to "FastestPath">>>>>> For the following path: e 15 27 9 12 26 32 The shortest time to the end is 68 <<<<<<<
The game of "FastestPath" consists of a path (a 1-D array) withn positive integers to represent n
cities in a path (except the first index which has always value 0). The aim of the game is to move
from the source city (located at index 0) to destination (located at last index) in the shortest time.
The value at each index shows the travel time to enter the city located in the corresponding index.
Here is a sample path where there are 6 cities (n is 6):
|
5
90 7
61 12
Always start the game from the first city and there are two types of moves. You can either move
to the adjacent city or jump over the adjacent city to land two cities over. The total travel time of
a game is the sum of the travel times of the visited cities.
In the path shown above, there are several ways to get to the end. Starting in the first city, our time
so far is 0. We could travel to city 2, then travel to city 4, then travel to last city for a total travel
time of 90 + 61 + 12 = 163. However, a fastest path would be to travel to city 1, then travel to city
3, and finally travel to last city, for a total travel time of 5 + 7+ 12 = 24.
Write a recursive solution to this problem that computes the shortest travel time of the game and
display in the output. Your program does not have to output the actual sequence of moves, only
the shortest travel time of this sequence.
Figure 2 and Figure 3 show the sample outputs.
Transcribed Image Text:The game of "FastestPath" consists of a path (a 1-D array) withn positive integers to represent n cities in a path (except the first index which has always value 0). The aim of the game is to move from the source city (located at index 0) to destination (located at last index) in the shortest time. The value at each index shows the travel time to enter the city located in the corresponding index. Here is a sample path where there are 6 cities (n is 6): | 5 90 7 61 12 Always start the game from the first city and there are two types of moves. You can either move to the adjacent city or jump over the adjacent city to land two cities over. The total travel time of a game is the sum of the travel times of the visited cities. In the path shown above, there are several ways to get to the end. Starting in the first city, our time so far is 0. We could travel to city 2, then travel to city 4, then travel to last city for a total travel time of 90 + 61 + 12 = 163. However, a fastest path would be to travel to city 1, then travel to city 3, and finally travel to last city, for a total travel time of 5 + 7+ 12 = 24. Write a recursive solution to this problem that computes the shortest travel time of the game and display in the output. Your program does not have to output the actual sequence of moves, only the shortest travel time of this sequence. Figure 2 and Figure 3 show the sample outputs.
Expert Solution
steps

Step by step

Solved in 2 steps with 1 images

Blurred answer
Knowledge Booster
Structured English
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
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education