Вы находитесь на странице: 1из 2

COMP2101 / CS20S Discrete Mathematics Complexity analysis Determine whether each statement is true or false in Exercises 1 2 is true or false.

e. If the statement is false give a counterexample. Assume that the functions f, g and h take on only positive values. 1. 2.
f (n) (h(n)) and g (n) (h(n)), then f (n) g (n) (h(n)) f (n) ( g (n)) and g (n) ( f (n)), then f (n) ( g (n))

SOLN. 14. Given f(n) = (h(n)) and g(n) = (h(n)) Show that f(n) + g(n) = (h(n)) f(n) = (h(n)) C1 | h(n) | | f(n) | C2 | h(n) | where C1 and C2 are constants C4 | h(n) | where C3 and C4 are constants (C2 + C4) | h(n) |

g(n) = (h(n)) C3 | h(n) | | g(n) |

By Addition (C1 + C3) | h(n) | C5 | h(n) |

| f(n) | + | g(n) |

| f(n) | + | g(n) | C6 | h(n) | where C5 and C6 are constants As f, g and h take on only positive values | f(n) | + | g(n) | = | f(n) + g(n) | Therefore C5 | h(n) | | f(n) + g(n) | C6 | h(n) | f(n) + g(n) = (h(n))

15. Given f(n) = O(g(n)) and g(n) = O(f(n)) Show that f(n) = (g(n)) f(n) = O(g(n)) | f(n) | g(n) = O(f(n))

C1 | g(n) | C2 | f(n) | | f(n) | | f(n) |

where C1 is a constant where C2 is a constant

| g(n) |

| g(n) | / C2 ( 1 / C2 ) | g(n) | C3 | g(n) |

| f(n) | | f(n) | | f(n) | or

where C3 is a new constant | f(n) | C3 | g(n) | or f(n) = (g(n))

C3 | g(n) | C3 | g(n) |

C1 | g(n) |

OR As

f(n) = (g(n)) = (g(n))

f(n) = O(g(n)) and f(n) = (g(n))

f(n)

Вам также может понравиться