1.

A greedy algorithm can be used to solve all the dynamic programming problems.(a) True(b) FalseThis question was posed to me in class test.This interesting question is from Dynamic Programming topic in chapter Dynamic Programming of Data Structures & Algorithms II

Answer»

Correct option is (b) False

The EXPLANATION is: A GREEDY ALGORITHM gives optimal solution for all subproblems, but when these locally optimal solutions are COMBINED it may NOT result into a globally optimal solution. Hence, a greedy algorithm CANNOT be used to solve all the dynamic programming problems.



Discussion

No Comment Found

Related InterviewSolutions