Javatpoint Logo
Javatpoint Logo

Greedy Algorithm Introduction

"Greedy Method finds out of many options, but you have to choose the best option."

In this method, we have to find out the best method/option out of many present ways.

In this approach/method we focus on the first stage and decide the output, don't think about the future.

This method may or may not give the best output.

Greedy Algorithm solves problems by making the best choice that seems best at the particular moment. Many optimization problems can be determined using a greedy algorithm. Some issues have no efficient solution, but a greedy algorithm may provide a solution that is close to optimal. A greedy algorithm works if a problem exhibits the following two properties:

  1. Greedy Choice Property: A globally optimal solution can be reached at by creating a locally optimal solution. In other words, an optimal solution can be obtained by creating "greedy" choices.
  2. Optimal substructure: Optimal solutions contain optimal subsolutions. In other words, answers to subproblems of an optimal solution are optimal.


  1. machine scheduling
  2. Fractional Knapsack Problem
  3. Minimum Spanning Tree
  4. Huffman Code
  5. Job Sequencing
  6. Activity Selection Problem

Steps for achieving a Greedy Algorithm are:

  1. Feasible: Here we check whether it satisfies all possible constraints or not, to obtain at least one solution to our problems.
  2. Local Optimal Choice: In this, the choice should be the optimum which is selected from the currently available
  3. Unalterable: Once the decision is made, at any subsequence step that option is not altered.

Youtube For Videos Join Our Youtube Channel: Join Now


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Trending Technologies

B.Tech / MCA