Practice free →
HomeGATE CSEcomputerscienceAlgorithms › A problem can be solved correctly by a greedy al…

A problem can be solved correctly by a greedy algorithm when it exhibits

Aoptimal substructure AND the greedy-choice property
Bany one of optimal substructure or the greedy-choice property
Cneither property; greedy works on all problems
Dthe dynamic-programming bellman equation
Answer & Solution
Correct answer: A. optimal substructure AND the greedy-choice property
Both properties are required. Optimal substructure says optimal solutions to sub-problems compose into an optimal solution; greedy-choice says the locally best choice is part of some globally optimal solution. Without BOTH, greedy may produce wrong answers (the ₹25/10/1 coin counter-example). Many problems have optimal substructure but not greedy-choice (knapsack, edit distance); those need DP.
Solve this in the app — GATE CSE practice & 24k+ MCQs →
Related questions