Greedy algorithm
Greedy algorithm always makes the choice that look
better at a brief period of time. i.e., it form a locally optimal choice in the hope that
this choice will lead to globally optimal solution.
The procedure is powerful and work in a good for wide range of problem.
An optimal problem is one in which you want to search, not only solution of problem, but better solution of a problem. Greedy algorithms works better for optimization problems.
An optimal problem is one in which you want to search, not only solution of problem, but better solution of a problem. Greedy algorithms works better for optimization problems.
A greedy algorithm works in different phases.
At each different phase:
At each different phase:
You desire the better you can obtain
right now, without consider for future result or effect.
You desire that by selecting a local
optimum at every step, you will end up at global optimum.
Example:
Example:
Suppose you want to count out a
certain value of money, using the few possible bills and coins. A greedy algorithm would do this in the following steps:
$1 bill to make $6
$25c coin, to make $6.25
10c coins to make $6.35
Four 1c coins to make $6.39
For US money the greedy algorithm
always give the optimum solution.
No comments:
Post a Comment