AI engineering glossary · Data structures algorithms

What is kruskal's algorithm?

Kruskal's algorithm: An algorithm that builds a minimum spanning tree by sorting all edges by weight and adding each edge in turn unless it would create a cycle, which it checks with a union-find structure. Time is O(E log E).

Level: intermediateTopic: Data structures algorithms

Kruskal's algorithm: an example

Edges of weight 1, 2, 3 are added first. A weight-4 edge joining two already connected cities is skipped to avoid a loop.

Related terms

More Data structures algorithms terms

Where you learn it

Kruskal's algorithm is part of the AI Engineering Program, which teaches it with notes, a hands-on lab and an exam. The first lesson is free.

Before you go

Take the cheat sheet with you

One free PDF: the key AI-engineering terms, formulas and Python idioms. No spam; unsubscribe any time.