Prim's Algorithm Basics

Updated Apr 28, 2026

Short answer

Building an MST by growing a tree from a starting node and adding the cheapest neighbor.

Deep explanation

Greedy algorithms are defined by the 'Greedy Choice Property'. Building an MST by growing a tree from a starting node and adding the cheapest neighbor. Unlike backtracking, once a choice is made, it is never reconsidered.

Real-world example

Giving change with the fewest coins in a standard currency.

Common mistakes

  • Assuming greedy works for all optimization problems without proof.

Follow-up questions

  • Is Greedy always faster than DP?

More Greedy Algorithms interview questions

View all →