Slideshare uses cookies to improve functionality and performance, and to provide you with relevant advertising. If you continue browsing the site, you agree to the use of cookies on this website. See our User Agreement and Privacy Policy.

Slideshare uses cookies to improve functionality and performance, and to provide you with relevant advertising. If you continue browsing the site, you agree to the use of cookies on this website. See our Privacy Policy and User Agreement for details.

Like this presentation? Why not share!

4,902 views

Published on

No Downloads

Total views

4,902

On SlideShare

0

From Embeds

0

Number of Embeds

2

Shares

0

Downloads

215

Comments

0

Likes

3

No embeds

No notes for slide

- 1. Big-Oh NotationAnd Some Others<br />J. Caleb Wherry<br />Austin Peay State University<br />Department of Computer Science<br />
- 2. Outline<br />Asymptotic Growth Classifications<br />Equivalence Classes<br /> Theta, Little Oh, Little Omega Notations<br />Big Oh, Big Omega Notations<br />Combination of Big Oh Expressions<br />Typical Growth Rates<br />2<br />
- 3. Asymptotic Growth Classifications<br />3<br />Asymptotic Growth: The rate at which a function grows. <br />“Growth rate” meaning the complexity of the function and /or the amount of resources it takes up to compute.<br />Given a differentiable function f(n), all other functions will fall into 1 of 3 asymptotic growth classifications:<br />Growing with the same rate.<br />Growing with a slower rate.<br />Growing with a faster rate. <br />
- 4. Equivalence Classes<br />4<br />Asymptotic growth creates a partition over the set of all differentiable functions.<br />These are better known as equivalence classes.<br />Meaning: Given a function in one class, it is equivalent with respect to its asymptotic growth to every other function in that class. <br />Who Cares and Why? <br />
- 5. L'Hôpital'sRule<br />5<br />Best Mathematical Tool for Helping With Growth Rates:<br />
- 6. Theta – Same Growth Rate<br />6<br />We choose f(n) and g(n) as two differentiable functions and say that they have the same growth rate if :<br />Formally stated as: <br />
- 7. Little Oh – Slower Growth Rate<br />7<br />We again choose f(n) and g(n) as two differentiable functions and say that f(n) grows slower than g(n) if:<br />Formally stated as: <br />
- 8. Little Omega – Faster Growth Rate<br />8<br />We again choose f(n) and g(n) as two differentiable functions and say that f(n) grows faster than g(n) if:<br />Formally stated as: <br />
- 9. Little Oh & Little Omega Together<br />9<br />Simple statement of the inverse relationship between Little Oh and Little Omega:<br />Examples<br />
- 10. Another Example<br />10<br />Let us try this one:<br />Which is correct?<br />
- 11. Big-Oh Notation<br />11<br />We again choose 2 differentiable functions f(n) and g(n) and say that f(n) grows with the same rate or slower than g(n) denoted by:<br />Logically broken down:<br />
- 12. Big-Omega Notation<br />12<br />We again choose 2 differentiable functions f(n) and g(n) and say that f(n) grows with the same rate or faster than g(n) denoted by:<br />Logically broken down:<br />
- 13. Big Oh & Big Omega Together<br />13<br />Simple statement of the inverse relationship between Big Oh and Big Omega:<br />
- 14. Big Oh Combinations <br />14<br />Say we want to find the asymptotic growth of 2 functions combined in some fashion. These 2 rules are the basis for doing these combinations:<br />
- 15. Other Rules<br />15<br />Rule 1:<br />Rule 2:<br />
- 16. Growth Rates<br />16<br /> C Constant, denoted O(1)<br />logN Logarithmic<br /> logN2 Log-squared<br /> N Linear <br />NlogNLinearithmic<br /> N2 Quadratic<br /> N3 Cubic<br /> 2N Exponential <br /> N! Factorial<br />
- 17. Question 1<br />17<br />What is the running time of this code piece?<br />int sum = 0;<br />for (inti = 0; i < n; i++) {<br />sum += i;<br />}<br />
- 18. Question 2<br />18<br />What is the running time of this code piece?<br />…<br />while (first <= last) {<br />int mid = (first + last) / 2;<br /> if (key > sortedArray[mid]) <br /> first = mid + 1; <br /> else if (key < sortedArray[mid]) <br /> last = mid - 1;<br /> else<br /> return mid;<br />}<br />…<br />
- 19. Final Question<br />19<br />What is the running time of this function?<br />public String makeSentence(String[] words) {<br /> String sentence = new String();<br /> for (String w : words) sentence.append(w);<br /> return sentence;<br />};<br />
- 20. Questions &| Comments<br />20<br />Questions &| Comments?<br />

No public clipboards found for this slide

×
### Save the most important slides with Clipping

Clipping is a handy way to collect and organize the most important slides from a presentation. You can keep your great finds in clipboards organized around topics.

Be the first to comment