Presentation is loading. Please wait.

Presentation is loading. Please wait.

Advanced Analysis of Algorithms

Similar presentations


Presentation on theme: "Advanced Analysis of Algorithms"— Presentation transcript:

1 Advanced Analysis of Algorithms
Lecture # 4 MS(Computer Science) Semester 1 Spring 2017

2 Asymptotic Notation After understanding Complexity rules & procedures, we can easily understand that the Time Complexity of any algorithm may be any one or multiple of the followings 1 Constant log n Logarithmic n Linear n2 Quadratic n3 Cubic 2n Exponential

3 Asymptotic Notation Let’s Assume the increasing order as 1 < log n < n < n log n < n2 < n3 ……. < 2n < 3n < nn Upper Bound Suppose f(n) = 2n2 + 3n + 2 Higher Degree is n2 All these time complexities greater than n2 becomes upper bound of function f(n). It also includes n2 So We can say f(n) = O(n2) f(n) = O(n3) f(n) = O(2n)

4 Asymptotic Notation Now Coming to Lower Bound Ω (Omega) 1 < log n < n < n log n < n2 < n3 ……. < 2n < 3n < nn Lower Bound Suppose f(n) = 2n2 + 3n + 2 Higher Degree is n2 All these time complexities smaller than n2 becomes lower bound of function f(n). It also includes n2 So We can say f(n) = Ω(n2) f(n) = Ω(n) f(n) = Ω(log n)

5 Asymptotic Notation f(n) = Φ(n2)
Now Coming to Tight Bound Φ (Theta) 1 < log n < n < n log n < n2 < n3 ……. < 2n < 3n < nn Tight Bound if f(n) = O(n2) and f(n) = Ω(n2) Then We can write f(n) = Φ(n2) Which is known as Tight Bound

6 Asymptotic notations f(n) = O(g(n))
If there exist positive constants c and n0 Such that f(n) < c x g(n) for all n >= n0 g(n) is an asymptotic upper bound for f(n)

7 Upper Bound (Big – Oh) f(n) = O(g(n)) We can write as
Let us Suppose a function f(n) f(n) = 2n2 + 3n + 1 Let’s Assume 2n2 + 3n2 + n2 = 6n2 We can write as 2n2 + 3n + 1 = 6n2 f(n) = c x g(n) Here c is 6 and g(n) = n2 So f(n) = O(n2 ) To Proof the Asymptotic Notation of Big – Oh which is f(n) = O(g(n)) If there exist positive constants c and n0 Such that f(n) < c x g(n) for all n >= n0 Consider n = 2 and solve the function f(n) = c g(n) 2n2 + 3n + 1 = 6n2 2x22 + 3x = 6 x 22 = 24 15 = 24 So f(n) < c x g(n) for all n > n0

8 Upper Bound (Big – Oh) f(n) = O(g(n)) We can write as
Let us Suppose a function f(n) f(n) = 2n2 + 3n + 1 Let’s Assume 22n + 32n + 2n = 62n We can write as 2n2 + 3n + 1 = 62n f(n) = c x g(n) Here c is 6 and g(n) = 2n So f(n) = O(2n ) To Proof the Asymptotic Notation of Big – Oh which is f(n) = O(g(n)) If there exist positive constants c and n0 Such that f(n) < c x g(n) for all n >= n0 Consider n = 2 and solve the function f(n) = c g(n) 2n2 + 3n + 1 = 62n 2x22 + 3x = 6 x 22 = 24 15 = 24 So f(n) < c x g(n) for all n > n0

9 Asymptotic notations f(n) = O(g(n))
If there exist positive constants c and n0 Such that f(n) > c x g(n) for all n >= n0 g(n) is an asymptotic Lower bound for f(n)

10 Upper Bound (Big – Omega)
Let us Suppose a function f(n) f(n) = 2n2 + 3n + 1 Let’s Assume n2 We can write as 2n2 + 3n + 1 = 1 x n2 f(n) = c x g(n) Here c is 1 and g(n) = n2 So f(n) = Ω (n2 ) To Proof the Asymptotic Notation of Big – Omega which is f(n) = Ω(g(n)) If there exist positive constants c and n0 Such that f(n) > c x g(n) for all n >= n0 Consider n = 2 and solve the function f(n) = c g(n) 2n2 + 3n + 1 = 1 x n2 2x22 + 3x = 1 x 22 = 4 15 = 4 So f(n) > c x g(n) for all n > n0

11 Asymptotic notations f(n) = O(g(n))
If there exist positive constants c1,c2 and n0 Such that c1g(n) < f(n) < c2 x g(n) for all n >= n0 g(n) is an asymptotic Tight bound for f(n)

12 Upper Bound (Big – Theta)
Let us Suppose a function f(n) f(n) = 2n2 + 3n + 1 f(n) = O(n2 ) and f(n) = Ω(n2 ) So according to Asymptotic Notation Φ (n2 ) Which is Known as Tight Bound

13


Download ppt "Advanced Analysis of Algorithms"

Similar presentations


Ads by Google