Greedy Algorithm vs Divide and Conquer Algorithm vs Dynamic Algorithm
Greedy Algorithm vs Divide and Conquer Algorithm vs Dynamic Algorithm
Algorithm:
Sl.N Dynamic
o Greedy Algorithm Divide and conquer Programming
It is used to obtain a
solution to the given
problem, it does not
It may or may not generate aim for the optimal It always generates
4 an optimal solution. solution optimal solution.
efficient and fast than divide less efficient and more efficient and
6 and conquer. slower. faster than greedy.
more memory is
required to store
extra memory is not some memory is subproblems for later
7 required. required. use.
Examples: 0/1
Examples: Fractional Examples: Merge sort, Knapsack,
Knapsack problem, Quick sort, All pair shortest path,
Activity selection problem, Strassen’s matrix Matrix-chain
8 Job sequencing problem. multiplication. multiplication.
Bellman Ford’s Algorithm Dijkstra’s Algorithm
Bellman Ford’s Algorithm works Dijkstra’s Algorithm may or may not work
when there is negative weight when there is negative weight edge. But
edge, it also detects the negative will definitely not work when there is a
weight cycle. negative weight cycle.
The result contains the vertices The result contains the vertices
which contains the information containing whole information about the
about the other vertices they are network, not only the vertices they are
connected to. connected to.