Give the graph annotated with edges that show the values in edgeTo. It should fo
ID: 3757444 • Letter: G
Question
Give the graph annotated with edges that show the values in edgeTo. It should form a tree rooted at 0. Formatting: write "[0] --> [1]" to indicate an edge from node 0 to 1. what are the nodes on the path from node 0 to node 6, and why is the path you gave the shortest path between 0 and 6??
Not sure, what this question nis asking. Is the anwser to this is:
[0]---->[1]
[0]---->[2]
[0]---->[3]
[1]---->[4]
[1]---->[5]
[2]---->[3] (do I need to add this one?)
[3]---->[4] (do I need to add this one?)
[4]---->[5] (do I need to add this one?)
[4]---->[6]
[5]---->[6] (do I need to add this one?)
[5]---->[7]
5 4 2Explanation / Answer
You might have been also given the weight of each edge with the description of the graph. If not we treat every edge have the same weight.
Now, the question is asking to find a path between 0 to 6, there are 9 such ways:
0->1->5->6
0->1->5->4->6
0->1->4->6
0->3->4->1->5->6
0->3->4->5->6
0->3->4->6
0->2->3->4->1->5->6
0->2->3->4->5->6
0->2->3->4->6
If all the edges weigh equal the shortest path is with minimum intermediate nodes (i.e. 2), there are 3 such paths:
0->1->5->6
0->1->4->6
0->3->4->6
If the weights are provided with the edges, you can choose among the total 9 paths, which result in overall minimum sum of weights for the intermediate nodes.
Hope this helps! PLEASE THUMBS UP!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.