Presentation is loading. Please wait.

Presentation is loading. Please wait.

Relations Over Asymptotic Notations. Overview of Previous Lecture Although Estimation but Useful It is not always possible to determine behaviour of an.

Similar presentations


Presentation on theme: "Relations Over Asymptotic Notations. Overview of Previous Lecture Although Estimation but Useful It is not always possible to determine behaviour of an."— Presentation transcript:

1 Relations Over Asymptotic Notations

2 Overview of Previous Lecture Although Estimation but Useful It is not always possible to determine behaviour of an algorithm using Θ-notation. For example, given a problem with n inputs, we may have an algorithm to solve it in a.n 2 time when n is even and c.n time when n is odd. OR We may prove that an algorithm never uses more than e.n 2 time and never less than f.n time. In either case we can neither claim  (n) nor  (n 2 ) to be the order of the time usage of the algorithm. Big O and  notation will allow us to give at least partial information Mashhood's Web Family mashhoood.webs.com 2

3 Definition: Let X be a non-empty set and R is a relation over X then R is said to be reflexive if (a, a)  R,  a  X, Example 1: Let G be a graph. Let us define a relation R over G as if node x is connected to y then (x, y)  G. Reflexivity is satisfied over G if for every node there is a self loop. Reflexive Relation Mashhood's Web Family mashhoood.webs.com 3

4 Example 1 Since, 0  f(n)  cf(n)  n  n 0 = 1,if c = 1 Hence f(n) = O(f(n)) Example 2 Since, 0  cf(n)  f(n)  n  n 0 = 1, if c = 1 Hence f(n) =  (f(n)) Example 3 Since, 0  c 1 f(n)  f(n)  c 2 f(n)  n  n 0 = 1,if c 1 = c 2 = 1 Hence f(n) =  (f(n)) Note: All the relations, , , O, are reflexive Reflexivity Relations over , , O Mashhood's Web Family mashhoood.webs.com 4

5 Example As we can not prove that f(n) 0 Therefore 1. f(n)  o(f(n)) and 2.f(n)   (f(n)) Note : Hence small o and small omega are not reflexive relations Little o and  are not Reflexivity Relations Mashhood's Web Family mashhoood.webs.com 5

6 Definition: Let X be a non-empty set and R is a relation over X then R is said to be symmetric if  a, b  X, (a, b)  R  (b, a)  R Example 1: Let P be a set of all persons, and B be a relation over P such that if (x, y)  B then x is brother of y. This relation is not symmetric because (Anwer, Sadia)  B  (Saida, Brother)  B Symmetry Mashhood's Web Family mashhoood.webs.com 6

7 Property : prove that f(n) =  (g(n))  g(n) =  (f(n)) Proof Since f(n) =  (g(n)) i.e. f(n)   (g(n))   constants c 1, c 2 > 0 and n 0  N such that 0  c 1 g(n)  f(n)  c 2 g(n)  n  n 0 (1) (1)  0  c 1 g(n)  f(n)  c 2 g(n)  0  f(n)  c 2 g(n)  0  (1/c 2 )f(n)  g(n)(2) (1)  0  c 1 g(n)  f(n)  c 2 g(n)  0  c 1 g(n)  f(n)  0  g(n)  (1/c 1 )f(n)(3) Symmetry over  Mashhood's Web Family mashhoood.webs.com 7

8 From (2),(3): 0  (1/c 2 )f(n)  g(n)  0  g(n)  (1/c 1 )f(n)  0  (1/c 2 )f(n)  g(n)  (1/c 1 )f(n) Suppose that 1/c 2 = c 3, and 1/c 1 = c 4, Now the above equation implies that 0  c 3 f(n)  g(n)  c 4 f(n),  n  n 0  g(n) =  (f(n)),  n  n 0 Hence it proves that, f(n) =  (g(n))  g(n) =  (f(n)) Symmetry over  Mashhood's Web Family mashhoood.webs.com 8

9 Definition: Let X be a non-empty set and R is a relation over X then R is said to be transitive if  a, b, c  X, (a, b)  R  (b, c)  R  (a, c)  R Example 1: Let P be a set of all persons, and B be a relation over P such that if (x, y)  B then x is brother of y. This relation is transitive this is because (x, y)  B  (y, z)  B  (x, z)  B Example 2: Let P be a set of all persons, and F be a relation over P such that if (x, y)  F then x is father of y. Of course this relation is not a transitive because if (x, y)  F  (y, z)  F  (x, z)  F Transitivity Mashhood's Web Family mashhoood.webs.com 9

10 Prove the following 1.f(n) =  (g(n)) & g(n) =  (h(n))  f(n) =  (h(n)) 2.f(n) = O(g(n)) & g(n) = O(h(n))  f(n) = O(h(n)) 3.f(n) =  (g(n)) & g(n) =  (h(n))  f(n) =  (h(n)) 4.f(n) = o (g(n)) & g(n) = o (h(n))  f(n) = o (h(n)) 5.f(n) =  (g(n)) & g(n) =  (h(n))  f(n) =  (h(n)) Note It is to be noted that all these algorithms complexity measuring notations are in fact relations which satisfy the transitive property. Transitivity Relation over , , O, o and  Mashhood's Web Family mashhoood.webs.com 10

11 Property 1 f(n) =  (g(n)) & g(n) =  (h(n))  f(n) =  (h(n)) Proof Since f(n) =  (g(n)) i.e. f(n)   (g(n))   constants c 1, c 2 > 0 and n 01  N such that 0  c 1 g(n)  f(n)  c 2 g(n)  n  n 01 (1) 2.Now since g(n) =  (h(n)) i.e. g(n)   (h(n))   constants c 3, c 4 > 0 and n 02  N such that 0  c 3 h(n)  g(n)  c 4 h(n)  n  n 02 (2) 3.Now let us suppose that n 0 = max (n 01, n 02 ) Transitivity Relation over  Mashhood's Web Family mashhoood.webs.com 11

12 4.Now we have to show that f(n) =  (h(n)) i.e. we have to prove that  constants c 5, c 6 > 0 and n 0  N such that 0  c 5 h(n)  f(n)  c 6 h(n)? (2)  0  c 3 h(n)  g(n)  c 4 h(n)  0  c 3 h(n)  g(n)(3) (1)  0  c 1 g(n)  f(n)  c 2 g(n)  0  c 1 g(n)  f(n)  0  g(n)  (1/c 1 )f(n)(4) From (3) and (4),0  c 3 h(n)  g(n)  (1/c 1 )f(n)  0  c 1 c 3 h(n)  f(n) (5) Transitivity Relation over  Mashhood's Web Family mashhoood.webs.com 12

13 (1)  0  c 1 g(n)  f(n)  c 2 g(n)  0  f(n)  c 2 g(n)  0  (1/c 2 )f(n)  g(n)(6) (2)  0  c 3 h(n)  g(n)  c 4 h(n)  0  g(n)  c 4 h(n)(7) From (6) and (7),0  (1/c 2 )f(n)  g(n)  (c 4 )h(n)  0  (1/c 2 )f(n)  (c 4 )h(n)  0  f(n)  c 2 c 4 h(n) (8) From (5), (8), 0  c 1 c 3 h(n)  f(n)  0  f(n)  c 2 c 4 h(n) 0  c 1 c 3 h(n)  f(n)  c 2 c 4 h(n) 0  c 5 h(n)  f(n)  c 6 h(n) And hence f(n) =  (h(n))  n  n 0 Transitivity Relation over  Mashhood's Web Family mashhoood.webs.com 13

14 Property 2 f(n) = O(g(n)) & g(n) = O(h(n))  f(n) = O(h(n)) Proof Since f(n) = O(g(n)) i.e. f(n)  O(g(n))   constants c 1 > 0 and n 01  N such that 0  f(n)  c 1 g(n)  n  n 01 (1) 2.Now since g(n) = O(h(n)) i.e. g(n)  O(h(n))   constants c 2 > 0 and n 02  N such that 0  g(n)  c 2 h(n)  n  n 02 (2) 3.Now let us suppose that n 0 = max (n 01, n 02 ) Transitivity Relation over Big O Mashhood's Web Family mashhoood.webs.com 14

15 Now we have to two equations 0  f(n)  c 1 g(n)  n  n 01 (1) 0  g(n)  c 2 h(n)  n  n 02 (2) (2)  0  c 1 g(n)  c 1 c 2 h(n)  n  n 02 (3) From (1) and (3) 0  f(n)  c 1 g(n)  c 1 c 2 h(n) Now suppose that c 3 = c 1 c 2 0  f(n)  c 1 c 2 h(n) And hence f(n) = O(h(n))  n  n 0 Transitivity Relation over Big O Mashhood's Web Family mashhoood.webs.com 15

16 Assignment Prove that 1.f(n) =  (g(n)) & g(n) =  (h(n))  f(n) =  (h(n)) 2.f(n) = o (g(n)) & g(n) = o (h(n))  f(n) = o (h(n)) 3.f(n) =  (g(n)) & g(n) =  (h(n))  f(n) =  (h(n)) To be submitted within the first lecture after Mid Term Mashhood's Web Family mashhoood.webs.com 16


Download ppt "Relations Over Asymptotic Notations. Overview of Previous Lecture Although Estimation but Useful It is not always possible to determine behaviour of an."

Similar presentations


Ads by Google