Greedy choice property:
The greedy-choice property is that a globally optimal solution can be arrived
at by making a locally optimal (greedy) choice. So to decide which choice to
make, make the choice that looks best in the current problem, without
considering results from sub problem.
The steps required to develop a Greedy
algorithm:
(i) Determine the optimal substructure of the
problem.
(ii) Develop a recursive solution.
(iii) Problem that at any stage of the recursion,
one of the optimal choices is the greedy choice. Thus, it is always safe to
make the greedy choice.
(iv) Show that all but one of the sub problems
induced by having made the greedy choice is empty.
(v) Develop a recursive algorithm that implements
the greedy strategy.
(vi) Convert the recursive algorithm to an iterative
algorithm.
No comments:
Post a Comment