Skip to main content

Greedy Algorithms

Greedy algorithms is type of problem solving method in programming tests.

why the word greedy?

Greedy algorithms take irreversible decisions based on a global rule.

  • Some values are greedy and dominate other values.
  • Making a decision based on the values in the current iteration.
  • Throw away previous decisions.

There are two types of greedy problems possible.

TypeIdea
Step greedychoose next best action
Structural greedyidentify dominating constraint and build around it

Examples

  1. CPU Task scheduling - the dominating constraint is first chosen.
  2. Increasing triple sequence - Every step just takes whatever best comes.