package practice; import edu.princeton.cs.algs4.StdRandom; public class TestMain { public static void main(String[] args) { int[] a = new int[20]; for (int i = 0; i < a.length; i++) { int temp = (int)(StdRandom.random()*100); a[i] = temp; } for (int…
#include <bits/stdc++.h> using namespace std; const int INF = 0x3f3f3f3f; const int maxn = 1005; bool vis[maxn]; int cost[maxn][maxn], lowc[maxn]; vector<int> demo; int prim(int cost[][maxn], int n) { int ans = 0; memset(vis, false, sizeof(vis…