Skip to content

Glossary: Algorithms Beyond the Basics in JavaScript

Greedy algorithm

Also written: greedy

An algorithm that takes the best-looking choice at each step and never goes back to change it. It is fast, but only right when something like a swap argument shows the choice is safe; with $10, $25 and $30 gift cards it gives the wrong answer for $50.

Where the book teaches it

Related terms

Greedy choiceSwap argumentInterval scheduling