Solutions-Graphs.pdf - Graph Algorithm Homework Solutions...

This preview shows page 1 - 2 out of 4 pages.

Graph Algorithm Homework Solutions Problem 1 Algorithm Design Instructions Note, write out your algorithm in words – no pseudocode. And make sure to state (and briefly explain) the running time of your algorithm. Problem 2 Computopia [DPV] Problem 3 Part (a): The directed graph G = ( V, E ) is constructed by having a vertex for each intersection and a directed edge for each one-way street. We run the SCC algorithm on G . We then check if the graph is strongly connected by checking if there is exactly 1 SCC. If G is strongly connected then it is possible to drive from any intersection to any other intersection. If there are multiple SCCs then it is not possible to do so. The SCC algorithm takes O ( n + m ) time so the total run time of our algorithm is also O ( n + m ) . Part (b): We need to check if the town-hall is in a sink SCC. We do this by checking that the vertices in the SCC containing the town-hall do not have any edges out of this SCC. (OK to just say check that the town-hall’s SCC is a sink SCC.) If the town-hall is in a sink SCC then no matter where you can reach starting from the town-hall then you can get back to town-hall. If it is not in a sink SCC then you cannot always get back to the town-hall. The running time of this part is also O ( n + m ) due to the SCC algorithm taking this time.

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture