0% found this document useful (0 votes)
15 views

12 Greeedy Method

The document discusses greedy algorithms for solving optimization problems. It defines key concepts like feasible and optimal solutions, and the objective function. It explains that greedy algorithms make locally optimal choices at each step to arrive at a global optimal solution. The greedy choice property and subset paradigm for greedy problems are described. Examples of greedy problems like knapsack, job scheduling and minimum spanning tree are provided. The document contrasts greedy algorithms with divide and conquer approaches.

Uploaded by

the477577
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)
15 views

12 Greeedy Method

The document discusses greedy algorithms for solving optimization problems. It defines key concepts like feasible and optimal solutions, and the objective function. It explains that greedy algorithms make locally optimal choices at each step to arrive at a global optimal solution. The greedy choice property and subset paradigm for greedy problems are described. Examples of greedy problems like knapsack, job scheduling and minimum spanning tree are provided. The document contrasts greedy algorithms with divide and conquer approaches.

Uploaded by

the477577
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/ 13

Design and Analysis of Algorithms

Greedy Method
2
3
Introduction to Optimization problem

• Optimization problems are those for which the objective is to Maximize or

Minimize some values. For example,

• Finding the minimum number of colors needed to color a given graph.

• Finding the shortest path between two vertices in a graph

4
Basis notations in Optimization problems
• A feasible solution is any subset of original input that satisfies a given set of
constraints.

• An objective function is an input for which a feasible solution is to be obtained


that either maximizes or minimizes.

• An optimal solution is a feasible solution which maximizes or minimizes the


objective function.

5
Greedy Method

• Greedy algorithm obtains an Optimal solution by making a sequence of decisions.

• Every greedy based problems will be given with a set of inputs and a set of constraints.

• Our objective is to find a solution vector which satisfies a set of constraints.

• Decisions are made one by one in some order.

• Each decision is made using a greedy-choice property or greedy criterion.

6
Greedy Choice Property
• Global Optimal Solutions will be made with local optimal (Greedy) choices

• In Greedy algorithm, the best choice will be selected at the moment to solve

the sub problem that remains

• The choice of the greedy may depend on the previous choices made but it

cannot depend on future choices or on the solutions to the sub problems

7
Types of Greedy Problems
• Subset Paradigm: To solve a problem (or possibly find the optimal/best
solution), greedy approach generate subset by selecting one or more available
choices.
Example:
• Knapsack problem
• Job sequencing with deadlines

8
Control abstraction for subset paradigm
Greedy(a,n) // a[1:n] contains the n inputs
{
solution= ϕ // Initialize solution
for i=1 to n do
{
x := Select(a);
if Feasible(solution , x) then
solution=Union(solution , x)
else
reject(); //if solution is not feasible
}
return solution;
}

9
Three Important Activities

1. Selection: Selection of solution from a[] and removes it


2. Feasibility: Feasible(solution,x) is a Boolean function to determine whether x can be
included into the solution vector

3. Optimality: From the set of feasible solutions, the particular solution which minimizes
or maximizes the given objective function

10
Applications of Greedy Method

• Knapsack Problem

• Job Sequencing with deadlines

• Minimum cost spanning tree

• Huffman Codes

• Single source shortest path problem

11
Divide and conquer Greedy Algorithm
Divide and conquer is used to find the solution, it does A greedy algorithm is optimization technique. It tries to
not aim for the optimal solution. find an optimal solution from the set of feasible solutions

DC approach divides the problem into small sub In greedy approach, the optimal solution is obtained from
problems, each sub problem is solved independently and a set of feasible solutions.
solutions of the smaller problems are combined to find
the solution of the large problem.

Sub problems are independent, so DC might solve same Greedy algorithm does not consider the previously solved
sub problem multiple time. instance again, thus it avoids the re-computation.

DC approach is recursive in nature, so it is slower and Greedy algorithms are iterative in nature and hence faster.
inefficient.

Divide and conquer algorithms mostly runs in Greedy algorithms also run in polynomial time but takes
polynomial time less time than Divide and conquer

Example: Example:
Merge sort, Knapsack problem,
12
Quick sort Job scheduling problem
Thank You

13

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy