Skip to content
Related Articles
Open in App
Not now

Related Articles

Comparison among Greedy, Divide and Conquer and Dynamic Programming algorithm

Improve Article
Save Article
  • Last Updated : 08 Nov, 2022
Improve Article
Save Article

Greedy Algorithm:

Greedy algorithm is defined as a method for solving optimization problems by taking decisions that result in the most evident and immediate benefit irrespective of the final outcome. It is a simple, intuitive algorithm that is used in optimization problems.

Divide and conquer Algorithm:

Divide and conquer is an algorithmic paradigm in which the problem is solved using the Divide, Conquer, and Combine strategy. A typical Divide and Conquer algorithm solve a problem using the following three steps:

Divide: This involves dividing the problem into smaller sub-problems.
Conquer: Solve sub-problems by calling recursively until solved.
Combine: Combine the sub-problems to get the final solution of the whole problem.

Dynamic Programming:

Dynamic Programming is mainly an optimization over plain recursion. Wherever we see a recursive solution that has sometimes repeated calls for the same input states, we can optimize it using Dynamic Programming. The idea is to simply store the results of subproblems so that we do not have to re-compute them when needed later. This simple optimization reduces time complexities from exponential to polynomial.

Greedy Algorithm vs Divide and Conquer Algorithm vs Dynamic Algorithm:

Sl.NoGreedy AlgorithmDivide and conquerDynamic Programming 
1Follows Top-down approachFollows Top-down approachFollows bottom-up approach
2Used to solve optimization problemUsed to solve decision problemUsed to solve optimization problem
3The optimal solution is generated without revisiting previously generated solutions; thus, it avoids the re-computationSolution of subproblem is computed recursively more than once.The solution of subproblems is computed once and stored in a table for later use.
4It may or may not generate an optimal solution. It is used to obtain a solution to the given problem, it does not aim for the optimal solutionIt always generates optimal solution.
5Iterative in nature.Recursive in nature.Recursive in nature.
6 efficient and fast than divide and conquer.less efficient and slower.more efficient and faster than greedy.
7extra memory is not required.some memory is required.more memory is required to store subproblems for later use.
8Examples: Fractional Knapsack problem,
Activity selection problem,
Job sequencing problem.
Examples: Merge sort,
Quick sort,
Strassen’s matrix multiplication.
Examples: 0/1 Knapsack,
All pair shortest path,
Matrix-chain multiplication.
My Personal Notes arrow_drop_up
Related Articles

Start Your Coding Journey Now!