Minimum spanning trees

What is the cost of the minimum spanning tree?

Examples

Worked example

Input
Triangle edges AB = 1, BC = 2, AC = 5
Expected output
3

Hints and solution

Hint 1

Write down the starting state and walk through one example by hand.

Reveal worked answer

Take AB and BC. They connect all three vertices at total cost 3, so AC would only add a cycle.

Back to the lesson