You are on page 1of 1
cs 502 gdb solution 1 sana majeed qu..1 An optimization problem is one in which you want to find, not just a solution, but the best solution. A “greedy algorithm” sometimes works well for optimization problems. -Agreedy algorithm worksin phases. At cach phase: 4. Youtakethebest you can getvight now, without regard fr future consequences. 2. Youhopa thatby choosinga lacalaptimumat eachstep, you willend upata globo optimum, ‘Greedy algorithms workby recursively constructing set of objects from the mallet poritle ‘constituent pats Recursion isan approachto problemsolving in whichthe solution toa particular prablem depends on solitons to smallerinstances ofthe same problem. The advantageto using # _ready algorithm that solutions to smaller instances ofthe problem can be straightforwardand easy ‘to understand. The dsadvartagelethat tis entirely possible that the most optimalshor-tarm solutions may lead tothe worst posiblalong-term outcome, In many problems, agreedy strategy ‘does notin general produce an optimal solution, but nonetheless a greedy heuristic may yield locally ‘optimal solutions that approximate a global optimal colutionin a reasonable time. Greedy algorithms ‘mostly (but not hvays) alt findthe globally optimal elution, because they usually donot operate ‘exhaustivelyonallthe data, Vv -

You might also like