Big-Oh NotationAnd Some Others<br />J. Caleb Wherry<br />Austin Peay State University<br />Department of Computer Science<...
Outline<br />Asymptotic Growth Classifications<br />Equivalence Classes<br /> Theta, Little Oh, Little Omega Notations<br ...
Asymptotic Growth Classifications<br />3<br />Asymptotic Growth: The rate at which a function grows. <br />“Growth rate” m...
Equivalence Classes<br />4<br />Asymptotic growth creates a partition over the set of all differentiable functions.<br />T...
L'Hôpital'sRule<br />5<br />Best Mathematical Tool for Helping With Growth Rates:<br />
Theta – Same Growth Rate<br />6<br />We choose f(n) and g(n) as two differentiable functions and say that they have the sa...
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)...
Little Omega – Faster Growth Rate<br />8<br />We again choose f(n) and g(n) as two differentiable functions and say that f...
Little Oh & Little Omega Together<br />9<br />Simple statement of the inverse relationship between Little Oh and Little Om...
Another Example<br />10<br />Let us try this one:<br />Which is correct?<br />
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 sam...
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 ...
Big Oh & Big Omega Together<br />13<br />Simple statement of the inverse relationship between Big Oh and Big Omega:<br />
Big Oh Combinations <br />14<br />Say we want to find the asymptotic growth of 2 functions combined in some fashion. These...
Other Rules<br />15<br />Rule 1:<br />Rule 2:<br />
Growth Rates<br />16<br />			C              Constant, denoted O(1)<br />logN         Logarithmic<br />			logN2        Log-...
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++) {<b...
Question 2<br />18<br />What is the running time of this code piece?<br />…<br />while (first <= last) {<br />int mid = (f...
Final Question<br />19<br />What is the running time of this function?<br />public String makeSentence(String[] words) {<b...
Questions &| Comments<br />20<br />Questions  &|  Comments?<br />
Upcoming SlideShare
Loading in...5
×

Big-Oh Notation

3,296

Published on

0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
3,296
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
147
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide

Big-Oh Notation

  1. 1. Big-Oh NotationAnd Some Others<br />J. Caleb Wherry<br />Austin Peay State University<br />Department of Computer Science<br />
  2. 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. 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. 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. 5. L'Hôpital'sRule<br />5<br />Best Mathematical Tool for Helping With Growth Rates:<br />
  6. 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. 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. 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. 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. 10. Another Example<br />10<br />Let us try this one:<br />Which is correct?<br />
  11. 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. 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. 13. Big Oh & Big Omega Together<br />13<br />Simple statement of the inverse relationship between Big Oh and Big Omega:<br />
  14. 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. 15. Other Rules<br />15<br />Rule 1:<br />Rule 2:<br />
  16. 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. 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. 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. 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. 20. Questions &| Comments<br />20<br />Questions &| Comments?<br />
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×