Suppose you must choose items without exceeding a capacity limit. A greedy algorithm makes the choice that looks best right now, without checking how that choice affects later options. That can be wonderfully simple—but will it produce the best total? section 7.1
When the best-looking item gets in the way
With a 10 kg limit, choosing an attractive 6 kg item first leaves 4 kg that cannot be used. Skipping it would allow two 5 kg items with a higher combined value. The first choice looked good locally but blocked the better combination. section 7.1
Capacity constraints matter even before comparing totals. For an eight-credit cloud-instance budget, choosing the two instances with the highest individual throughput values costs nine credits. That choice is invalid, not merely less efficient. For indivisible items, a dynamic-programming matrix instead compares taking and skipping each item across capacities. section 7.1
Greedy selection is not always the wrong tool. In fractional knapsack, materials can be divided: sort them by value per unit of weight, take the most valuable first, and use a fraction of the last material to fill the remaining capacity. This strategy reaches the optimum for that variant because a partly filled gap need not be wasted. section 7.3
The same short-sighted pattern can appear in route search. If an ant colony optimization algorithm gives too much weight to immediate distance, it effectively picks the closest next node each time and ignores information from the swarm. section 8.3















