Analysis of Algorithm
Analysis of Algorithm
Sushma Prajapati
Assistant Professor
CO Dept
CKPCET,surat
Email:[email protected]
Outline
The efficient algorithm
Asymptotic Notations
Example
Complexity Of Algorithm(Contd…)
Space Comlexity Examples:
Given function f(n) and g(n), we say that f(n) is О(g(n)) if there are positive constants c >
0 and n0 ≥ 1 , such that
If we simplify n >= 2.
Therefore for every n >= 2 and c = 4, f(n) <= c g(n). So f(n) = O g(n).
Asymptotic Notations(Big omega Notation)
The Big-Ω notation provides an asymptotic lower bound .
Given function f(n) and g(n), we say that f(n) is Ω(g(n)) if there are positive constants c >
0 and n0 ≥ 1 such that
Now check can this f(n) has lower bound as g(n) or not.
By this method the running time is between upper bound and lower bound.
Asymptotic Notations(Big theta Notation)
Graphical representation of theta notation
Asymptotic Notations(Big theta Notation)
F(n) = 3n+2, g(n) = n
F(n) <= c g(n) where c = 4; That is 3n+2 <= 4n. This is valid for all n0>= 2.So we can say
g(n) is upper bound for f(n).
F(n) >= c g(n); That is 3n+2 >= n. where n0 >= 1.So both the cases are valid for this.
Properties of Asymptotic Notations
Let f and g be the functions and a and b be the real numbers.
1. f(x) is O(g(x)) ⇔ a ≤ b
2. f(x) is Ω(g(x)) ⇔ a ≥ b
3. f(x) is Θ(g(x)) ⇔ a = b
Computation Time = tA + tB
= (max (tA,tB)