03 Algorithm Analysis
03 Algorithm Analysis
FACULTY OF S CIENCE ,
S HARQ I NSTITUTE OF H IGHER E DUCATION
Algorithm Analysis
Number of input
BY: ABDUL WARIS 3
E XAMPLE
Y
2n+1 3n
Running time
3n
1 0
2n+1 3 3
5 6
X 7 9
Number of input
BY: ABDUL WARIS 4
E XAMPLE
F(n) = n4+2n2+100n+500
F(n) = n4 for some n > n0
1 constant
log n logarithmic
n linear
n log n n-log-n
n2 quadratic
n3 cubic
2n exponential
To analyze the given algorithm , we need to know on what inputs the algorithm is taking
less time and on what inputs the algorithm is taking huge time .
Worst case
Average case
Best case
Insertion sort
Introduction
Algorithm
Analysis
Run time calculation