Design And Analysis Of Algorithms Week 4 Quiz Solution


 

We are given a directed graph, represented as an adjacency list, in which each vertex has at least one incoming edge and one outgoing edge. We would like to print out for each vertex j the list of vertices pointing into j. What is the most accurate description of the complexity of computing these quantities in terms of n, the number of vertices, and m, the number of edges?

 O(n2)

 O(nm)

 O(m)

 O(n)


Consider the following strategy to convert an undirected graph with negative edge weights to one that does not have negative edge weights. Let the maximum magnitude negative edge weight in the graph be -k. Then, for each edge in the graph with weight w, update the weight to w+k+1. Consider the following claim:

To solve the shortest path problem in the original graph, we can run Dijkstra's algorithm on the modified graph and subtract the added weights to get the original distances.

Which of the following is not correct.

 The claim is not true in general.

 The claim is not true in general for graphs with cycles.

 The claim is true for connected acyclic graphs.

 The claim is true for all graphs.


Consider the following algorithm on a connected graph with edge weights.
Sort the edges as [e1,e2,...,em] in decreasing order of cost.
Start with the original graph. Consider each edge ej. If this edge is part of a cycle delete it.

Which of the following is not true.

 At most n-1 edges will be deleted.

 After processing all m edges, the resulting graph is connected.

 What remains at the end is a minimum cost spanning tree.

 Exactly m-n+1 edges will be deleted.


Consider the following strategy to solve the single source shortest path problem with edge weights from source s.
Replace each edge with weight w by w edges of weight 1 connected by new intermediate nodes
Run BFS(s) on the modified graph to find the shortest path to each of the original vertices in the graph.

Which of the following statements is correct?

 This strategy will solve the problem correctly and is as efficient as Dijkstra's algorithm.

 This strategy will solve the problem correctly but is not as efficient as Dijkstra's algorithm.

 This strategy will only work if the graph is acyclic.

 This strategy will not solve the problem correctly.


Suppose we have a graph with negative edge weights. We take the largest magnitude negative edge weight -k and reset each edge weight w to w+k+1. Which of the following is true?

 Kruskal's algorithm will identify the same spanning tree on the new graph as on the old graph.

 Minimum cost spanning trees in the original graph will not correspond to minimum cost spanning trees in the new graph.

 Prim's algorithm will not work on the modified graph but will work on the original graph.

 There are more minimum cost spanning trees in the modified graph than in the original graph.

Post a Comment (0)
Previous Question Next Question

You might like