Professional Documents
Culture Documents
Design and Analysis of Algorithm: Bscs3 Prof Hashim Javed
Design and Analysis of Algorithm: Bscs3 Prof Hashim Javed
Analysis of
Algorithm
BS Cs 3rd
Such algorithms are called greedy because while the optimal solution
to each smaller instance will provide an immediate output, the
algorithm doesn’t consider the larger problem as a whole. Once a
decision has been made, it is never reconsidered
Greedy Algorithm Works on
following property
2.Optimal Substructure:
Optimal solution contain optimal Sum Solution
Greedy Algorithm
3 1
A C
8
5 7
D
Considering the Above Diagram Suppose We have to move from A
to C
Then there are three possible Solutions
From A to B from B to C
From A to D from D to C
OR
Directly From A to C
But For this we have to calculate this
which is the most minimum solution for
this path For which we can travel Easily
Another Example
B
4
1
A C
10
5 2
D