What is a Greedy Approach?
A Greedy approach is one of the most famous techniques utilised to solve problems. We can say that it is an algorithm used for solving the problem by choosing the best option open at the moment. This technique does not focus on the optimal result or whether the current result will impact the optimal output or not.
Also, this technique follows the top-down approach and never changes the judgement even if the option is wrong.
What is Dynamic Programming?
Dynamic Programming (DP) is a method used for decrypting an optimization problem by splitting it down into easier subproblems so that we can reuse the results. These techniques are mainly used for optimization. Some important pointers related to dynamic programming are mentioned below:
- The problem should be able to be split into easier subproblems or overlapping sub-problem.
- We can get the optimum solution through the optimum output of smaller subproblems.
- This algorithm technique prefers memoization.
Difference between Greedy Approach and Dynamic Programming
S.No. | Greedy Method | Dynamic Programming |
1 | In a Greedy Algorithm, we make our decision based on the best current situation. | In Dynamic Programming, we select individually in every step, however, the selection may rely on the solution to sub-problems. |
2 | In this technique, there is no assurance of obtaining the optimal solution. | In this technique, you can get the assurance of an optimal solution. |
3 | Greedy approach is used to get the optimal solution. | Dynamic programming is also used to get the optimal solution. |
4 | The greedy method never alters the earlier choices, thus making it more efficient in terms of memory. | This technique prefers memoization due to which the memory complexity increases, making it less efficient. |
5 | Greedy techniques are faster than dynamic programming. | Dynamic programming is comparatively slower. |
Keep learning and stay tuned to get the latest updates on GATE Exam along with GATE Eligibility Criteria, GATE 2023, GATE Admit Card, GATE Application Form, GATE Syllabus, GATE Cut off, GATE Previous Year Question Paper, and more.
Also Explore,
Comments