ics141-lecture13-Complexity

# ics141-lecture13-Complexity - 1 ICS 141 Discrete...

This preview shows pages 1–9. Sign up to view the full content.

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: 1 ICS 141: Discrete Mathematics I (Spr 2008) University of Hawaii ICS141: Discrete Mathematics for Computer Science I Department of Information and Computer Sciences University of Hawaii Stephen Y. Itoga 2 ICS 141: Discrete Mathematics I (Spr 2008) University of Hawaii Lecture 13 Chapter 3. The Fundamentals 3.2 The Growth of Functions 3.3 Complexity of Algorithms 3 ICS 141: Discrete Mathematics I (Spr 2008) University of Hawaii • Some material in these slides were taken/adapted from the slides made by Prof. Michael P. Frank and Prof. Jonathan L. Gross which are provided through the publisher of “Discrete Mathematics and Its Applications” written by Kenneth H. Rosen. • Some slides were done by Prof. Baek 4 ICS 141: Discrete Mathematics I (Spr 2008) University of Hawaii Review: Big-O Notation • Let f and g be functions R (or Z ) → R . • Definition: “ f is big-O of g ” (or “ f is in the class O( g )”) if 5 C , k such that |f ( x )| ≤ C|g ( x )| 2200 x ≥ k . – “Beyond some point k , function f is at most a constant C times g ( i.e., proportional to g ).” – f is bounded from above by g • “f is at most order g ”, or “f is O( g ) ( f is big-oh of g ) ”, or “ f = O( g )” all just mean that f ∈ O( g ). • Often the phrase “at most” is omitted. • The constants C and k are called witnesses to the relationship f ( x ) is O( g ( x )). 5 ICS 141: Discrete Mathematics I (Spr 2008) University of Hawaii Review:Big-O and Polynomials • Theorem 1 : Let f ( x ) = a n x n + a n- 1 x n- 1 +···+ a 1 x + a (i.e. f ( x ) is a polynomial of degree n ), where a , a 1 ,..., a n- 1 , a n are real numbers. Then f ( x ) is O( x n ). – Proof : Using the triangle inequality (| a + b |≤| a |+| b |), if x ≥ 1 we have | f ( x )| = | a n x n +a n-1 x n-1 + ⋯ +a 1 x+a | ≤ | a n | x n + | a n-1 | x n-1 + ⋯ + | a 1 | x+ | a | = x n (| a n | + | a n-1 |/ x+ ⋯ + | a 1 |/ x n-1 + | a |/ x n ) ≤ x n (| a n | + | a n-1 | + ⋯ + | a 1 | + | a |). – This shows that | f ( x )|≤ Cx n , where C = | a n | + | a n-1 | + ⋯ + | a 1 | + | a | whenever x ≥ 1. – Hence, f ( x ) is O ( x n ). 6 ICS 141: Discrete Mathematics I (Spr 2008) University of Hawaii Examples • 1 + 2 + ··· + n ≤ n + n + ··· + n + n = n 2 . It follows that 1 + 2 + ··· + n is O( n 2 ) , taking C = 1 and k = 1 as witnesses. • n! = 1 2 3 ⋅ ⋅ ⋅⋯⋅ n ≤ n ⋅ n ⋅ n ⋅⋯⋅ n = n n ∴ n! is O ( n n ) • log n! ≤ log n n = n log n ∴ log n! is O ( n log n ) • n ≤ 2 n whenever n is a positive integer n n n n n i n n i 2 1 2 1 2 ) 1 ( 2 1 2 1 + = + = = + + + ∑ = : Note 7 ICS 141: Discrete Mathematics I (Spr 2008) University of Hawaii Order of Growth of Functions A Display of the Growth of Functions Commonly Used in Big-O Estimates • Important complexity classes O(1) ⊂ O(log n ) ⊂ O( n ) ⊂ O( n log n ) ⊂ O( n 2 ) ⊂ O( c n ) ⊂ O( n !) 8 ICS 141: Discrete Mathematics I (Spr 2008) University of Hawaii...
View Full Document

## This note was uploaded on 09/12/2008 for the course ICS 141 taught by Professor Idk during the Fall '08 term at Hawaii.

### Page1 / 34

ics141-lecture13-Complexity - 1 ICS 141 Discrete...

This preview shows document pages 1 - 9. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online