In the coin change problem, take denominations and target amount . The natural greedy algorithm repeatedly chooses the largest denomination not exceeding the remaining amount. It chooses , then , then , for three coins. Yet uses only two.
Two is optimal: one coin cannot make because denomination is absent, and the displayed pair attains the lower bound. ThereforeThe locally largest first coin loses the possibility of using the better pair of threes. This supplies a concrete failure of the greedy-choice property; optimal substructure alone does not justify the greedy choice. The dynamic programming recurrence from part (b) would compare all feasible first or last denominations and find the pair.
Articles by others on the same topic
There are currently no matching articles.