A greedy algorithm breaks a large problem into smaller subproblems, chooses an optimal solution for each, and combines those choices. Because each choice is made for its subproblem rather than the whole problem, the combined result can be suboptimal. section 9.2
Making change
For 73 cents in US coins, choosing the largest available coin first yields two quarters, two dimes, and three pennies: seven coins. But without nickels, the same strategy makes 41 cents with eight coins; four dimes and a penny needs only five. Greedy choices can be quick and useful, but need not be globally optimal. section 9.2
Pretty printers use greedy algorithms to reformat code quickly, where an acceptable result may be preferable to waiting for an optimal one. section 9.0 section 9.2











