Page 1 of 1

Question 7 : Graphs - Tourist Path.. 10 points In this problem, you're going to find the path taken by a tourist on a gi

Posted: Sun May 15, 2022 8:49 am
by answerhappygod
Question 7 Graphs Tourist Path 10 Points In This Problem You Re Going To Find The Path Taken By A Tourist On A Gi 1
Question 7 Graphs Tourist Path 10 Points In This Problem You Re Going To Find The Path Taken By A Tourist On A Gi 1 (100.31 KiB) Viewed 52 times
You can assume NUMNODES, ver, and adj are
global variables (i.e., you can access all of them from your
function).
You have access to the following function for
your Queue: /* Add element x to queue */
This should be the only required Queue function since
you’re only adding elements to the already
created itinerary.
Complete the recursive function “tour” which enqueues
the path taken by the tourist into the
given Queue called itinerary.
}
Question 7 : Graphs - Tourist Path.. 10 points In this problem, you're going to find the path taken by a tourist on a given undirected graph G going from S to F and save that sequence of vertices in a queue which represents the itinerary of their trip. Some of the vertices in the graph are Points of Interest that the tourist wants to visit if given the opportunity. Specifically, here's the rules they follow: • The tourist starts from the given node S. • The tourist will stop once they're at their destination (i.e. S == F). The function returns true and no more paths are explored or enqueued to the itinerary. • The tourist chooses the next node to go to from the current, X, as follows: - Any unvisited Points of Interest adjacent to X. - Any unvisited node adjacent to X. - The most recent node they went through on their way to X and repeat these choices from there. If there are multiple choices of where to go, they break ties by going to the one with the smallest index in the graph's array of nodes, ver. For example suppose they started from 0 and they were traveling to 8 in the graph below. Each vertex is labeled with its index in the graph's vertex array. The nodes {3,4,7,8,9} are Points of Interest that the tourist will prioritize visiting. 2 3 10 10 8 F The algorithm should store the following in its itinerary queue: 042 40137578 These are the nodes on the red path followed by the tourist according to the above rules.