0% found this document useful (0 votes)
29 views4 pages

Greedy Method

Greedy algorithms make locally optimal choices at each step to find a global optimum solution, often leading to satisfactory results in optimization problems. They are effective when the greedy choice property and optimal substructure are present, but may not always yield the best solution due to their lack of backtracking and reliance on problem structure. Applications include constructing minimum spanning trees and solving various optimization problems, though they can struggle with negative graph edges.

Uploaded by

vidyas.bsccs2020
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)
29 views4 pages

Greedy Method

Greedy algorithms make locally optimal choices at each step to find a global optimum solution, often leading to satisfactory results in optimization problems. They are effective when the greedy choice property and optimal substructure are present, but may not always yield the best solution due to their lack of backtracking and reliance on problem structure. Applications include constructing minimum spanning trees and solving various optimization problems, though they can struggle with negative graph edges.

Uploaded by

vidyas.bsccs2020
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/ 4

Abstract

Introduction
Greedy Method
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. The key idea is to select the best
possible choice at each step, leading to a solution that may not always be the
most optimal but is often good enough for many problems. It works for cases
where minimization or maximization leads to the required solution. It is
called “greedy” because it tries to find the best solution by making the best
choice at each step, without considering future steps or the consequences of
the current decision.
Optimization
Optimization refers to the process of finding the best possible solution from all
feasible solutions. An optimal problem, in this context, is one that seeks to find
the optimal solution, which could involve maximizing or minimizing an
objective function while satisfying certain constraints.

If both of the properties below are true, a greedy algorithm can be used to solve
the problem.

 Greedy choice property: A global (overall) optimal solution can


be reached by choosing the optimal choice at each step.
 Optimal substructure: A problem has an optimal substructure if
an optimal solution to the entire problem contains the optimal
solutions to the sub-problems.

Why choose Greedy Approach?


The greedy approach has a few trade offs, which may make it suitable for
optimization. One prominent reason is to achieve the most feasible solution
immediately. In the activity selection problem (Explained below), if more activities
can be done before finishing the current activity, these activities can be performed
within the same time. Another reason is to divide a problem recursively based on a
condition, with no need to combine all the solutions. In the activity selection
problem, the “recursive division” step is achieved by scanning a list of items only
once and considering certain activities.
How does the Greedy Algorithm works?
1. To begin with, the solution set (containing answers) is empty.

2. At each step, an item is added to the solution set until a solution is reached.

3. If the solution set is feasible, the current item is kept.

4. Else, the item is rejected and never considered again.

Example: suppose we want to find the longest path in the graph below from root to leaf.
Let's use the greedy algorithm here.

 Let's start with the root node 20. The weight of the right child is 3 and the
weight of the left child is 2.
 Our problem is to find the largest path. And, the optimal solution at the
moment is 3. So, the greedy algorithm will choose 3.
 Finaly the weight of an only child of 3 is 1. This gives us our final result 20 +
3 + 1 = 24.
 However, it is not the optimal solution. There is another path that carries
more weight (20 + 2 + 10 = 32) as shown in the image below.

Tree Vertex Splitting


The tree vertex splitting problem (TVSP) is a network optimization problem that

arises in various applications, such as booster placement, multicast routing, and

network reliability. The problem is to find a minimum set of vertices in a weighted

tree that can be split into two copies, such that the maximum edge weight in the

resulting tree is less than or equal to a given tolerance limit.

Applications of Greedy Algorithm

Following are few applications of the greedy algorithm:

 Used for Constructing Minimum Spanning Trees: Prim’s and


Kruskal’s Algorithms used to construct minimum spanning trees
are greedy algorithms.

 Used to Implement Huffman Encoding: A greedy algorithm is


utilized to build a Huffman tree that compresses a given image,
spreadsheet, or video into a lossless compressed file.

 Used to Solve Optimization Problems: Graph - Map Coloring,


Graph - Vertex Cover, Knapsack Problem, Job Scheduling Problem,
and activity selection problem are classic optimization problems
solved using a greedy algorithmic paradigm.

Advantages of Greedy Method

1. The greedy algorithm makes judgments based on the information


at each iteration without considering the broader problem; hence
it does not produce the best answer for every problem.

2. The problematic part for a greedy algorithm is analyzing its


accuracy. Even with the proper solution, it is difficult to
demonstrate why it is accurate.

3. Optimization problems (Dijkstra’s Algorithm) with negative graph


edges cannot be solved using a greedy algorithm.
Disadvantages of Greedy Algorithm
1. Lack of global optimization: Greedy algorithms make locally
optimal choices at each step without considering the overall
solution. As a result, they may not always lead to the globally
optimal solution. The greedy approach may overlook future
consequences and make choices that seem optimal at the moment
but turn out to be suboptimal in the long run.
2. Lack of backtracking: Greedy algorithms do not backtrack or
reconsider decisions made earlier. Once a choice is made, it is not
revisited, even if better options become available later. This can
lead to suboptimal solutions or even incorrect results.
3. Dependency on problem structure: Greedy algorithms heavily
rely on the problem's structure and the specific criteria used to
make greedy choices. Different problem structures may require
different criteria for selecting the next step, and the same greedy
algorithm may not work well for all problem instances.
Conclusion

You might also like