0% found this document useful (0 votes)
11 views9 pages

3.1 General Method

The document discusses the greedy approach, a technique used for solving optimization problems by making decisions based on currently available information without considering future consequences. It outlines the components of a greedy algorithm, including candidate sets, selection functions, feasibility functions, and objective functions, and provides an example of traveling from point A to B with various solutions. Additionally, it highlights applications of the greedy algorithm in finding the shortest path, minimum spanning trees, job sequencing, and the fractional knapsack problem.

Uploaded by

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

3.1 General Method

The document discusses the greedy approach, a technique used for solving optimization problems by making decisions based on currently available information without considering future consequences. It outlines the components of a greedy algorithm, including candidate sets, selection functions, feasibility functions, and objective functions, and provides an example of traveling from point A to B with various solutions. Additionally, it highlights applications of the greedy algorithm in finding the shortest path, minimum spanning trees, job sequencing, and the fractional knapsack problem.

Uploaded by

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

Module 3.

1
Greedy Approach

Pradnya Bhangale
[email protected]
Introduction
• The greedy method is one of the strategies like Divide and
conquer used to solve the problems.
• This method is used for solving optimization problems.
• An optimization problem is a problem that demands either
maximum or minimum results.
• The Greedy method is the simplest and straightforward
approach.
• It is not an algorithm, but it is a technique.
• Main function: decision is taken on the basis of the currently
available information.
Decision is made without worrying about the effect of the
current decision in future.
Introduction
• This technique is basically used to determine the feasible
solution that may or may not be optimal.
• The feasible solution is a subset that satisfies the given criteria.
• The optimal solution is the solution which is the best and the
most favorable solution in the subset.
• In the case of feasible, if more than one solution satisfies the
given criteria then those solutions will be considered as the
feasible, whereas the optimal solution is the best solution
among all the solutions.
Pseudo code of Greedy Algorithm

• Solution is assigned with zero


value
• Pass the array and number of
elements in the greedy
algorithm.
• Inside the for loop, we select
the element one by one and
checks whether the solution is
feasible or not.
• If the solution is feasible, then
we perform the union.
Components of Greedy Algorithm
• Candidate set: A solution that is created from the set is known
as a candidate set.
• Selection function: This function is used to choose the
candidate or subset which can be added in the solution.
• Feasibility function: A function that is used to determine
whether the candidate or subset can be used to contribute to
the solution or not.
• Objective function: A function is used to assign the value to
the solution or the partial solution.
• Optimal/ Solution function: This function is used to intimate
whether the complete function has been reached or not.
Example
• Suppose there is a problem 'P'. I want to travel from A to B
shown as below:
P:A→B
• The problem is that we have to travel this journey from A to B.
• There are various solutions to go from A to B.
• Candidate Solution : walk, car, bike, train, airplane, etc.
• Selection Function: complete journey within 12 hrs.
• Feasible solutions: one by train and another one by air
• Objective: cover the journey at the minimum cost (minimization
problem)
• Optimal Solution: travelling by train will lead to the minimum cost
Applications of Greedy Algorithm
• It is used in finding the shortest path
• It is used to find the minimum spanning tree using the prim's
algorithm or the Kruskal's algorithm
• It is used in a job sequencing with a deadline
• It is used to solve the fractional knapsack problem
Thank You!

You might also like