Can someone tell me where we use Dynamic/Greedy algorithm and how we trace from the question that it will solved by any one of the above?
Thanks
Computer Science Stack Exchange is a question and answer site for students, researchers and practitioners of computer science. It only takes a minute to sign up.
Sign up to join this communityCan someone tell me where we use Dynamic/Greedy algorithm and how we trace from the question that it will solved by any one of the above?
Thanks
Greedy Algorithm:
An algorithm that always takes the best immediate, or local, solution while finding an answer. Greedy algorithms find the overall, or globally, optimal solution for some optimization problems, but may find less-than-optimal solutions for some instances of other problems. [1].
Problems that can be solved by a Greedy Algorithm will have two properties:
Essentially, Greedy Algorithms solve combinatorial problems having the properties of matroid.
For more detail you can consult Introduction to Algorithm.
Dynamic Programming:
Solve an optimization problem by caching subproblem solutions (memoization) rather than recomputing them. [2]
Dynamic Programming algorithms are often used for optimization because it will examine the previously solved subproblems and will combine their solutions to give the best solution for the given problem.
Now, problems that can be solved by a Dynamic Programming Algorithm will have this necessary condition:
Principle of Optimality: An optimal policy has the property that whatever the initial state and initial decision are, the remaining decisions must constitute an optimal policy with regard to the state resulting from the first decision. [3]