Kruskal’s Algorithm in C — Minimum Spanning Tree with Union-Find

Kruskal’s algorithm finds the minimum spanning tree (MST) of a weighted, connected, undirected graph — the cheapest possible set of edges that connects every vertex with no cycles. It’s the classic greedy approach: sort all edges by weight, then keep taking the cheapest edge that doesn’t form a cycle. Road networks, electrical wiring, and network …

Dijkstra’s Algorithm in C – Shortest Path with Step-by-Step Trace

Dijkstra’s algorithm finds the shortest path from one source vertex to all other vertices in a weighted graph with non-negative edge weights. It is a greedy algorithm: at each step it picks the unvisited vertex with the smallest known distance, marks it done, and relaxes its neighbours — updating any neighbour’s distance if a shorter …