AI engineering glossary · Data structures algorithms

What is prim's algorithm?

Prim's algorithm: An algorithm that grows a minimum spanning tree from a start vertex, repeatedly adding the cheapest edge that connects the tree to a new vertex, usually using a priority queue. It works well on dense graphs.

Level: intermediateTopic: Data structures algorithms

Prim's algorithm: an example

Starting at one village, it always adds the cheapest road to a village not yet connected until all are joined.

Related terms

More Data structures algorithms terms

Where you learn it

Prim'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.