What is a Greedy Algorithm?

Technology CommunityCategory: Greedy AlgorithmsWhat is a Greedy Algorithm?
VietMX Staff asked 3 years ago

We call algorithms greedy when they utilise the greedy property. The greedy property is:

At that exact moment in time, what is the optimal choice to make?

Greedy algorithms are greedy. They do not look into the future to decide the global optimal solution. They are only concerned with the optimal solution locally. This means that the overall optimal solution may differ from the solution the greedy algorithm chooses.

They never look backwards at what they’ve done to see if they could optimise globally. This is the main difference between Greedy Algorithms and Dynamic Programming.