-1

I try to solve this question but I am not sure of my solution

the quetion

This is my solution: I use Kruskal algorithm and I choose the edges that will make (a) leaf solution

thank you.

Manal
  • 43
  • 4

1 Answers1

0

No. The answer will be 9. The algorithm takes edges:
a<->b with cost 1: ADDED a,b are now connected
a<->d with cost 1: ADDED a,b,d are now connected
b<->d with cost 4: SKIPPED
c<->d with cost 7: ADDED a,b,d,c are now connected, this is the final spanning tree.
a<->c with cost 8: SKIPPED
b<->c with cost 12: SKIPPED

So, the answer is 1+1+7=9.

  • but like this the node (a) will not be a leaf of the tree ?? – Manal May 06 '16 at 22:30
  • 1
    Ah, I see. Then your answer is correct. But you cannot use Kruskal algorithm, because it does not guarantee any node to be a leaf in the final spanning tree. Kruskal algorithm would give you the answer i gave, that is 9. In such small graph you can easily find all possible spanning trees and compare them. But if you want non-brute force algorithm to find minimal spanning tree with this additional requirement you will need different algorithm than Kruskal, and I don't know at the moment what algorithm would you need. – Karol Kalinowski May 06 '16 at 22:57
  • thank you , i found an example of this questuin and like you said no need for Kruskal. – Manal May 06 '16 at 23:10