in Algorithms edited by
12,331 views
45 votes
45 votes

Let $G=\left ( V,E \right )$ be $any$ connected, undirected, edge-weighted graph. The weights of the edges in $E$ are positive and distinct. Consider the following statements:

  1. Minimum Spanning Tree of $G$ is always unique.
  2. Shortest path between any two vertices of $G$ is always unique.

Which of the above statements is/are necessarily true?

  1. I only
  2. II only
  3. both I and II
  4. neither I nor II
in Algorithms edited by
by
12.3k views

1 comment

second one does not hold true every time.
0
0

5 Answers

76 votes
76 votes
Best answer

Answer is A.

  • MST is not unique only when edges are not distinct. Here the edges are distinct. Be careful for the keyword DISTINCT.
     
  • Shortest Path can be different even if the edges are distinct. Example is shown below. Shortest path from A to C is not unique here.

pic

edited by
by

4 Comments

nice explanation ...
6
6
But the graph given in the question is said to be undirected...
2
2
It wont change anything, make it undirected. The reasoning still holds.
0
0
Yes,  it would not make any difference even if it was directed, anyway I edited the image.
1
1
12 votes
12 votes
Only 1 is true because if you take an example of 3 vertices with weights as 1,2 &3 ..

A---1------B

B------2--------C

C--------3---------A

 

 

1.   Minimum spanning tree would weigh 1+2=3 (only one mst possible with AB & BC)

2.   whereas  it wouldn't have a unique shortest path between two of them.

1+2=3 possible (AB +BC) & only 3 possible (CA)  ~ two possibilities

Correct me if I am wrong!

2 Comments

However your solution is true but aprroch could ve wrong because according to algorithm if there is two path between two varticea are same than it selects path with minimum no. of vertices!

 

is this from set-1??
0
0
yes set I
0
0
8 votes
8 votes
Option 1 is CORRECT as Weights are Distinct hence only 1 minimum spanning tree is possible

(Think it this way..you are applying KRUSKAL algorithm...now each time min heap will return you Unique minimum weight edge so only 1 tree possible)

Option 2 INCORRECT as below

   A      (1)       B

  (2)               (4)

  C       (3)       D

here path 1(A--B--D) has weight=5

path 2(A--C--D) has weight 5

So answer is OPTION (A)

1 comment

Heaps are not used in kruskal but in prims. Disjoint sets are used in kruskal.
0
0
4 votes
4 votes
onli 1st is true
by
Answer:

Related questions