0% found this document useful (0 votes)
2 views3 pages

Greedy Algorithms

Greedy algorithms are optimization techniques that make locally optimal choices at each step to achieve a globally optimal solution, relying on the greedy choice and optimal substructure properties. Key components include feasibility and optimality checks, ensuring that selected choices meet constraints and produce desired extremum values. These algorithms are applicable in various real-life problems such as the knapsack problem, minimum spanning tree, and job scheduling.

Uploaded by

suganya.cse
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views3 pages

Greedy Algorithms

Greedy algorithms are optimization techniques that make locally optimal choices at each step to achieve a globally optimal solution, relying on the greedy choice and optimal substructure properties. Key components include feasibility and optimality checks, ensuring that selected choices meet constraints and produce desired extremum values. These algorithms are applicable in various real-life problems such as the knapsack problem, minimum spanning tree, and job scheduling.

Uploaded by

suganya.cse
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

Greedy algorithms are a class of algorithms that make locally optimal choices at each step with the

hope of finding a global optimum solution. In these algorithms, decisions are made based on the
information available at the current moment without considering the consequences of these
decisions in the future.

What is Greedy Algorithm?

A greedy algorithm is a type of optimization algorithm that makes locally optimal choices at each
step to find a globally optimal solution. It operates on the principle of “taking the best option now”
without considering the long-term consequences.

Greedy choice property:

This property says that the globally optimal solution can be obtained by making a locally optimal
solution (Greedy). The choice made by a Greedy algorithm may depend on earlier choices but not on
the future. It iteratively makes one Greedy choice after another and reduces the given problem to a
smaller one.

Optimal substructure:

A problem exhibits optimal substructure if an optimal solution to the problem contains optimal
solutions to the subproblems. That means we can solve subproblems and build up the solutions to
solve larger problems.

Characteristic components of greedy algorithm:

1. The feasible solution: A subset of given inputs that satisfies all specified constraints of a
problem is known as a “feasible solution”.

2. Optimal solution: The feasible solution that achieves the desired extremum is called an
“optimal solution”. In other words, the feasible solution that either minimizes or maximizes
the objective function specified in a problem is known as an “optimal solution”.

3. Feasibility check: It investigates whether the selected input fulfils all constraints mentioned
in a problem or not. If it fulfils all the constraints then it is added to a set of feasible
solutions; otherwise, it is rejected.

4. Optimality check: It investigates whether a selected input produces either a minimum or


maximum value of the objective function by fulfilling all the specified constraints. If an
element in a solution set produces the desired extremum, then it is added to a sel of optimal
solutions.

5. Optimal substructure property: The globally optimal solution to a problem includes the
optimal sub solutions within it.

6. Greedy choice property: The globally optimal solution is assembled by selecting locally
optimal choices. The greedy approach applies some locally optimal criteria to obtain a partial
solution that seems to be the best at that moment and then find out the solution for the
remaining sub-problem.

The local decisions (or choices) must possess three characteristics as mentioned below:

1. Feasibility: The selected choice must fulfil local constraints.

2. Optimality: The selected choice must be the best at that stage (locally optimal choice).
3. Irrevocability: The selected choice cannot be changed once it is made.

Steps for Creating a Greedy Algorithm

The steps to define a greedy algorithm are:

1. Define the problem: Clearly state the problem to be solved and the objective to be
optimized.

2. Identify the greedy choice: Determine the locally optimal choice at each step based on the
current state.

3. Make the greedy choice: Select the greedy choice and update the current state.

4. Repeat: Continue making greedy choices until a solution is reached.

Pseudo code of Greedy Algorithm

Algorithm Greedy (a, n)

Solution : = 0;

for i = 0 to n do

x: = select(a);

if feasible(solution, x)

Solution: = union(solution , x)

return solution;

}}

Applications of Greedy Approach:

Greedy algorithms are used to find an optimal or near optimal solution to many real-life
problems. Few of them are listed below:

(1) Make a change problem

(2) Knapsack problem

(3) Minimum spanning tree

(4) Single source shortest path

(5) Activity selection problem

(6) Job sequencing problem

(7) Huffman code generation.


(8) Dijkstra’s algorithm

(9) Greedy coloring

(10) Minimum cost spanning tree

(11) Job scheduling

(12) Interval scheduling

(13) Greedy set cover

(14) Knapsack with fractions

You might also like