Professional Documents
Culture Documents
Solutions
Solutions
Solutions
Question 1:
Question 2:
Create a new adjacency-list Adj of size |V| and an empty matrix M of size |V|^2 first.
For each vertex u in the multigraph G, we iterably examine each vertex v of Adj[u].
•If M(u, v) == ∅, mark M(u, v) true, then add v to Adj[u]
•If M(u, v) == true, do nothing.
Since we lookup in the adjacency-list Adj for |V + E| times, the time complexity is O(V + E
EQUIVALENT-UNDIRECTED-GRAPH
let Adj'[1..|V|] be a new adjacency-list
let M be |V| × |V|
for each vertex u ∈ G.V
for each v ∈ Adj[u]
if M[u, v] == Ø && u != v
M[u, v] = true
INSERT(Adj'[u], v)
Question 3:
Proof by contradiction:
Let T and T’ be two minimum spanning trees which differ by at least one edge.
Let this edge be (u, v). Therefore, edge (u, v) is an element of T, but not an element of T’
Since (u, v) is not an element of T’, there exists another element of T’, mainly (x, y) which
crosses some cut in G.
Now suppose either (u, v) or (x, y) is the light edge crossing the cut.
Since (u, v) is not an element of T’, there exists some path in T’ from u to v. This path must
cross the cut somewhere at (x, y).
Therefore, cut (x, y) from T’ and add (u, v) to reduce the weight of the tree.