Exercise: Print Shortest Path

Print the shortest path obtained as a result of running BFS.

We'll cover the following

The task at hand

There are six lines of code on the right. Five of these are to be dragged and dropped on the left to complete the definition of the function ShowPath.

The ShowPath function takes two parameters: the source vertex ss and the vertex vv . It is required to print the shortest path from ss to vv, found by running the BreadthFirstShortestPath function. Assume that we have run BreadthFirstShortestPath as discussed in the previous lesson, on a digraph.

Get hands-on with 1200+ tech skills courses.