We will represent the distances between the buildings as a weighted graph.
Step 1: Sort the edges in ascending order of their weights.
AB: 5, AC: 7, AD: 8, AE: 10, BC: 6, BD: 9, BE: 11, CD: 4, CE: 3, DE: 6
Sorted edges: CE: 3, CD: 4, AB: 5, BC: 6, DE: 6, AC: 7,
Show more…