SLU MATH135 algorithms

# SLU MATH135 algorithms - Complexity of algorithms Discrete...

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

Complexity of algorithms Discrete Math MATH 135 David Oury Introduction Big-O/ Ω / Θ Definitions Examples Theorems Exercises Algorithms & complexity Introduction Search Sort Exercises Recursion Exercises Complexity of algorithms Discrete Math MATH 135 David Oury November 3, 2011 Chapter 3, Sections 1, 2, 3 (5 lectures) of Discrete Mathematics and its Applications, by Rosen

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

View Full Document
Complexity of algorithms Discrete Math MATH 135 David Oury Introduction Big-O/ Ω / Θ Definitions Examples Theorems Exercises Algorithms & complexity Introduction Search Sort Exercises Recursion Exercises Introduction Goals 1 Define the “big-O/ Ω / Θ ” notations for comparing functions based on the rate at which they increase 2 Compare certain functions 3 Understand theorems to aid in comparison 4 Read and write procedures using operations (atomic and control flow) 5 Count atomic operations required for a procedure to complete “in the worst case” 6 Describe the complexity of procedures using this notation.
Complexity of algorithms Discrete Math MATH 135 David Oury Introduction Big-O/ Ω / Θ Definitions Examples Theorems Exercises Algorithms & complexity Introduction Search Sort Exercises Recursion Exercises Definition: big-O, big- Ω & big- Θ I Let f and g be functions R R or Z R . Definition: big-O We write f = O ( g ( x )) and say “ f is big-O of g ” when there are constants C and k such that | f ( x ) | ≤ C | g ( x ) | if x > k . f grows more slowly then some fixed multiple of g C K x ( K < x → | f ( x ) | ≤ C · | g ( x ) | ) Use this to understand the negation, when f is not O ( g ) . Definition: big- Ω We write f = Ω( g ( x )) and say “ f is big- Ω of g ” when there are constants C and k such that C | g ( x ) | ≤ | f ( x ) | if x > k . f grows more quickly then some fixed multiple of g

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

View Full Document
Complexity of algorithms Discrete Math MATH 135 David Oury Introduction Big-O/ Ω / Θ Definitions Examples Theorems Exercises Algorithms & complexity Introduction Search Sort Exercises Recursion Exercises Definition: big-O, big- Ω & big- Θ II Definition: big- Θ We write f = Θ( g ( x )) and say “ f is big- Θ of g or that “ f is the order of g ” when f = O ( g ( x )) and f = Ω( g ( x )) .
Complexity of algorithms Discrete Math MATH 135 David Oury Introduction Big-O/ Ω / Θ Definitions Examples Theorems Exercises Algorithms & complexity Introduction Search Sort Exercises Recursion Exercises Examples: big-O, big- Ω & big- Θ I Example: n i =1 i = O ( n 2 ) 1 Notice that n i =1 i = n ( n + 1) / 2 = n 2 / 2 + n/ 2 . 2 Then n 2 / 2 + n/ 2 n 2 / 2 + n 2 / 2 = n 2 for n 1 . 3 Then n i =1 i = O ( n 2 ) by k = 1 and C = 1 . Example: n 1=1 i = Ω( n 2 ) 1 Then n 1=1 i (1 / 2) n 2 since n 1=1 i = n 2 / 2 + n/ 2 . 2 Then n 1=1 i = Ω( n 2 ) by k = 1 and C = 1 / 2 . Example: n i =1 i = Θ( n 2 ) By previous theorems, n 1=1 i = O ( n 2 ) and n 1=1 i = Ω( n 2 ) .

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

View Full Document
Complexity of algorithms Discrete Math MATH 135 David Oury Introduction Big-O/ Ω / Θ Definitions Examples Theorems Exercises Algorithms & complexity Introduction Search Sort Exercises Recursion Exercises Examples: big-O, big- Ω & big- Θ II Example: n 2 is not O ( n ) Need to show that ¬∃ C k n ( n > k n 2
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### What students are saying

• As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

Kiran Temple University Fox School of Business ‘17, Course Hero Intern

• I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

Dana University of Pennsylvania ‘17, Course Hero Intern

• The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

Jill Tulane University ‘16, Course Hero Intern