×

Algorithms Tutorial

Searching Algorithms

Dynamic Programming

Graph Algorithms

Backtracking Algorithms

Recursion

Operating System Algorithms

Miscellaneous Topics

Introduction to Greedy Strategy Algorithm

In this tutorial, we will learn about the introduction of greedy strategy, algorithm for greedy strategy, some applications and the elements of greedy strategy in Analysis and Design of Algorithms. By Prerana Jain Last updated : August 12, 2023

Greedy Strategy Algorithm

The solution is determined by a sequence of steps each step has given a particular solution and later a complete solution to given the problem can be achieved. In short, while making a choice there should be a greed for the optimum solution.

Some points about Greedy strategy:

  • Look for the optimal solution and assumes it as best.
  • Solves the sub-problems in Top-down manner.
  • This approach is less powerful programming techniques.
  • It is not applicable to a wider area like dynamic programming approach.
  • It is useful for solving optimization problems.
  • It generates only one solution sequences.

Activities

In greedy strategy following activities are performed,

  1. First, select some solutions from input domain.
  2. Then check whether the solution is feasible or not.
  3. In this, we find an optimum solution which satisfies the objective of the function and it can be obtained from a particular solution out of the set of feasible solution.
  4. As greedy method works in stages only one stage is considered at a time. Based on this input it is decided whether a particular input is given the optimal solution or not.

Algorithm for Greedy Strategy

In greedy approach D is domain, from which solution is to be obtained of size n...

Initially assume
Solution  ← 0
For i ← 1 to n do
{
	S ← select(D) // section of solution from D
	If (Feasible (solution) then
	Solution ← Union (solution, s);
}
Return solution

Elements of Greedy Strategy

Greedy Choice Property

  • A global optimal solution can be arrived by local optimal choice.
  • For finding the solutions to the problem the subproblems are solved and best from these sub-problems is considered.
  • This choice may depend upon the previously made choices but it does not depend on any future choice.
  • Thus in the greedy method, greedy choices are made one after the another, reducing each given problem instances to smaller one.

Optimal Sub-structure

  • If an optimal solution to the problem containing the optimal solution to the subproblem then the problem shows an optimal substructure.
  • A problem has optimal substructure if has been next choices always leads to an optimal solution.

Applications of Greedy Method

Problems that can be solved by greedy approach,

  1. Knapsack problem
  2. Prim’s algorithm for minimum spanning tree.
  3. Kruskal’s algorithm for minimum spanning tree.
  4. Finding shortest job
  5. Job sequencing with deadlines
  6. Optimal storage on taps
  7. Huffman coding

Feasible Solution

The set of values for the decision problem which satisfies all of the constraints of an optimization problem then the solution is called feasible solution. Feasible solution satisfy all linear and non-linear constraints. The set of all feasible solution defines the feasible region of the problem. To solve a problem first find anyone feasible solution and then try to find another feasible solution which satisfies the values of the objective functions. The whole process is repeated until when no further improvement is achieved or other criteria are met.

Related Tutorials

Comments and Discussions!

Load comments ↻





Copyright © 2024 www.includehelp.com. All rights reserved.