Greedy Algorithm - Introduction

 
What is a Greedy Algorithm?
  • A Greedy Algorithm is an algorithm or rather a technique, that always makes a choice that seems to be the best at the moment. This means that it makes a locally optimal choice assuming that this choice will result in a globally optimal solution of the given problem. 
  • As a Greedy Algorithm assumes that the choice it made at the local level is the best choice available at that moment, hence the Greedy Algorithm has only one shot to compute the optimal solution of the given problem. The Greedy Solution never goes back and reverses its decision.
Where Should we use a Greedy Algorithm?
  • When we see that the given problem has Optimal Substructure then we can use the Greedy Algorithm to solve that problem. Optimal Substructure means that optimal solution to the subproblems (optimal local solution) can lead to the optimal solution of the whole problem (optimal global solution).
Common Greedy Algoritms
Good Resources for practicing Greedy Algorithms
 

Comments

Popular posts from this blog

Binary Heap - Introduction

Divide and Conquer - Introduction

Bubble Sort