AI engineering glossary · Data structures algorithms
What is greedy algorithm?
Greedy algorithm: An algorithm that builds a solution step by step, always choosing the option that looks best right now and never reconsidering. It gives optimal answers for some problems, but for others only approximate ones.
Greedy algorithm: an example
Giving change of 41 in coins 25, 10, 5, 1 by taking the largest coin each time gives 25, 10, 5, 1, which is optimal for this coin set.
Related terms
More Data structures algorithms terms
- Hash table
- Heap sort
- Heapify
- Heuristic
- Huffman coding
- In-place algorithm
- Insertion sort
- Interval scheduling
Where you learn it
Greedy 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.