Question 2: The game of "FastestPath" consists of a path (a 1-D array) with n positive integers to represent n cities in a path (except the first index which has always value 0). The aim of the game...


Question 2:<br>The game of >>>>>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: 0 15 27 9 12 26 32 The shortest time to the end is 68 Figure 3: Sample output "/>
Extracted text: Question 2: The game of "FastestPath" consists of a path (a 1-D array) with n 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): 0 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. >>>>>>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: 0 15 27 9 12 26 32 The shortest time to the end is 68 Figure 3: Sample output
Jun 04, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here