Sample Final
Sample Final
Problem 1. (10 marks) In big O notation for worst case, what is the time complexity of:
a) mergsort.
b) finding summation of n numbers with n processors.
c) Maximum-Cost Spanning Tree.
d) Single-Source Longest Paths in a weighted directed graph with non-positive weights.
e) All-pair shortest paths.
Problem 2. (5 marks) a). (4 marks) Prove, by using the definitions of O and Ω, the following:
n = O (n − log2 (n))
2n − n = Ω(2n )
Problem 3. (10 marks) (Short answer. Your answer should be yes or no. If the answer is no, explain
why)
a) Dijkstra algorithm for Single-Source Shortest Paths works even if there are negative weights.
b) Dijkstra method for finding Single-Source Shortest Paths can be used to find the Single-Source
Longest Paths assuming that all the weights are non-negative.
c) Minimum-Cost Spanning Tree for a graph will not change if all the weights are multiplied by a
constant c.
d) Graphs G1 and G2 have the same transitive closure iff G1 = G2 .
e) If 3SAT is not in P then Graph 3-coloring is in P .
Problem 5. (15 marks) Given a connected, undirected, weighted graph G = (V, E), define the cost
of a spanning tree to be the maximum weight among the weights associated with the edges of the
spanning tree.
Design an efficient algorithm to find the spanning tree of G which maximize above defined cost.
What is the complexity of your algorithm.
1
Problem 6. (15 marks) Let G = (V, E) be a connected, undirected, weighted graph with non-
negative weights. Let v be a vertex of G. Given a spanning tree T of G, denote by c(v, w) the
summation of the weights along the simple path from v to w on T (c(v, v)=0)). We then define the
cost of spanning tree T by
cost(T ) = max c(v, w).
w∈V
Design an efficient algorithm to find the spanning tree of G which minimize this cost.