Sample 2
Sample 2
1. (Easy) If all the edges in the graph have equal weights, then show that you can find the minimum spanning tree
in O(m + n) time.
2. (Easy) In the heart of New Delhi, esteemed mathematician Professor Gupta introduces a novel approach for
computing minimum spanning trees, inspired by India’s rich mathematical heritage. His algorithm unfolds as
follows: Given a graph G = (V, E), partition the vertex set V into two sets V1 and V2 such that |V1 | and |V2 | differ
by at most 1. Let E1 be the set of edges incident solely on vertices in V1 , and E2 be the set of edges incident
solely on vertices in V2 . Recursively solve the minimum spanning tree problem on the subgraphs G1 = (V1 , E1 )
and G2 = (V2 , E2 ). Finally, select the minimum-weight edge in E that crosses the cut V1 , V2 , and use this edge to
unite the resulting two minimum spanning trees into a single spanning tree. Evaluate whether Professor Gupta’s
algorithm correctly computes a minimum spanning tree of G, or provide a counterexample to demonstrate its
limitations.
Either argue that the algorithm correctly computes a minimum spanning tree of G, or provide an example for
which the algorithm fails.
3. (Medium) You are given a graph G and its minimum spanning tree M. Design an efficient algorithm that updates
M when:
(a) A new edge e is added to the graph.
(b) An edge e is deleted from the graph.
4. (Medium) Show that if all the weight in the graph are distinct, then there is a unique minimum spanning tree
in the graph.
5. (Medium) You are given a graph G and its minimum spanning tree M. Design an algorithm to find if M is the
unique M in G in O(mn) time. Now assume that you have an access to an oracle that can tell you the maximum
weight edge on the path between any two vertices in M in O(log n) time. Now show that you can find M is
unique (or not) in O(m log n) time.
6. (Medium) Let e be the edge in the graph with maximum weight. That is, all the other edges have weight strictly
less that w(e) in the graph. Show that e cannot lie in the minimum spanning tree of G.
7. (Hard) Show that for any graph G with minimum spanning trees T and T ′ , that for each weight w, T and T ′
contain the same number of edges of weight w.
8. (Hard) In the class, we did Prim’s and Kruksal’s algorithm. But there is another algorithm that predates both
of them – Boruvka’s algorithm. We will assume that all the edges have distinct weight in the graph G
9. (Hard) You are given a graph G and an edge e ∈ G. You want to find if e is in the minimum spanning tree of
G or not. Design an algorithm that performs this task in O(m) time.
10. (Hard) All edges of the graph G can be partitioned into k classes. Each edge in class i has cost ci . The cost of
each edge class is different. You can purchase all edges of class i by paying ci rupees. Your task is to purchase
the minimum number of edge classes that contain the minimum spanning tree of G. Design an algorithm that
accomplishes this task in O(m log n) time.
11. (Hard) In the country of Mallaga, there are n cities and m roads of three types: red, blue, and green. Men can
travel on red and green roads, while women can travel on blue and green roads. To minimize maintenance costs,
the ruler wants to destroy some roads while ensuring the country remains connected for both men and women.
What is the maximum number of roads that can be destroyed? Design an efficient algorithm for this problem.
12. (Hard) A graph is a nearly a tree if it has n + k edges where k is a small constant. Show that you can find a
minimum spanning tree in such a graph in O(nk) time.
13. (Hard) Design an efficient algorithm to find a spanning tree for a connected, weighted, undirected graph such
that the weight of the maximum weight edge in the spanning tree is minimized. Prove the correctness of your
algorithm.