Algorithms

Greedy algorithm

An algorithm that, at each step, picks what looks best right now, without looking at the steps ahead.

Example

To give 31 in change with bills of 1, 5, 10 and 20: first 20, then 10, then 1. That's 3 bills.

Test yourself: Greedy algorithm

What is an algorithm

What does a greedy algorithm do at each step?

Lessons that use it

More algorithms terms

All terms →

Arki, the beaver mascot

Your next interview starts with 5 minutes today.

Free on iOS and Android. Start from zero, no account needed.