Foundations
Linear Structures
Hashing
Array and String Patterns
Recursion, Search, and Sorting
Problem Solving Patterns
Algorithm Searching
Sorting Algorithms
Array Algorithms
Grid Algorithms
Linear Structure Algorithms
Hashing Algorithms
Recursion and Backtracking
Greedy Algorithms
Tree and Heap Algorithms
Graph Algorithms
Dynamic Programming Algorithms
String Algorithms
Math Algorithms
Keyboard ready
Space plays. Arrow keys step. R restarts.
LAB Kruskal MST Lab
Graphs
Problem shape
Intermediate
A
B
C
D
E
Core idea
Sort edges by weight and add edges that connect different components.
Step 1 / 5
Problem shape
Graphs Intermediate
Kruskal MST
Welcome to the Kruskal MST algorithm lab. Sort edges by weight and add edges that connect different components. Use it when: Use for minimum spanning tree on sparse graphs. The time complexity is O(E log E), and the space complexity is O(V). The pseudocode is: sort edges by weight for edge in edges if find(u) != find(v) take edge union(u, v) As you practice, track the state that changes and the condition that makes the algorithm stop.
Time
O(E log E)
Space
O(V)
Pseudocode
sort edges by weight
for edge in edges
if find(u) != find(v)
take edge
union(u, v) 1.0x