Prototype: implement prototype(int n, List<Edge> edges) returning Mst with a direct baseline.

Final: implement solve(int n, List<Edge> edges) with the mechanism and bounds described above. Undirected weights may be negative. Normalize edges to min/max endpoints, then process by weight/from/to, rejecting self-loops and cycles. Return Mst(totalCost, acceptedEdges) in acceptance order, or null when disconnected. Valid n=0/1 returns cost zero and empty edges. Reject negative n or invalid endpoints. Both stages have the same observable contract. The prototype may use the simpler method; final must use the target data structure.

The supplied nested record types define the API. All methods are static members of Exercise.

Drag or use the arrow keys to resize. Home collapses the question; End collapses the editor. Enter or double-click resets the split.
Loading editor…
No results yet.

Complete the starter code, then run the checks.
Results and errors will appear here.

Java runs on this device with CheerpJ 4.3.