Professional Documents
Culture Documents
CHARACTERISTICS AND
FEATURES
To construct the solution in an optimal way. Algorithm
Maintains two sets,
-One contains chosen items and
-The other contains rejected items.
Greedy algorithms make good local choices in the hope that
They result in,
-An optimal solution.
-Feasible solutions.
CONTINUED
The greedy algorithm consists of four (4) function.
A function that checks whether chosen set of items provide a
solution.
A function that checks the feasibility of a set.
The selection function tells which of the items is the most
promising.
An objective function, which does not appear explicitly, gives
the value of a solution.
OPTIMIZATION PROBLEMS
An optimization problem:
Given a problem instance, a set of constraints and an
objective function.
Find a feasible solution for the given instance for which the
objective function has an optimal value.
Either maximum or minimum depending on the problem being
solved.A feasible solution that does this is called optimal
solution.
8
Continued
Feasible:
A feasible solution satisfies the problems constraints
Constraints:
The constraints specify the limitations on the required
solutions.
TSP
The Problem is how to travel from city A
and visit all city on the map, then back to
city A again.
Solution:
Find the shortest path from city A(start) to
any other city.
A
Keep tuning on
Soon end
George Dantzig proposed a greedy approximation algorithm to solve the unbounded knapsack problem.[19] His version
sorts the items in decreasing order of value per unit of weight,
. It then proceeds to insert them into the sack,
starting with as many copies as possible of the first kind of item until there is no longer space in the sack for more.
Provided that there is an unlimited supply of each kind of item, if
is the maximum value of items that fit into the
sack, then the greedy algorithm is guaranteed to achieve at least a value of
. However, for the bounded
problem, where the supply of each kind of item is limited, the algorithm may be far from optimal.
Advantage of Greedy
Greedy is easy to be implemented.
Just search the best choice from the
current state that reachable (has
any paths or any connections).
In simple case, greedy often give you
the best solution.
Drawback of Greedy
In large and complex case, greedy
doesnt always give you the best
solution, because its just search and
take the best choice that you can
reach from the current state.
It takes longer time than any other
algorithms for big case of problem