csci 246 class 8
play

CSCI 246 Class 8 ASYMPTOTIC NOTATION Quiz Questions Lecture 14: - PowerPoint PPT Presentation

CSCI 246 Class 8 ASYMPTOTIC NOTATION Quiz Questions Lecture 14: What is the Big- O notation for Euclids Algorithm runtime? Lecture 15: Show f(n) = 10n + 5 is in O(n 2 ) Notes Modified Office Hours Today Midterm


  1. CSCI 246 – Class 8 ASYMPTOTIC NOTATION

  2. Quiz Questions  Lecture 14:  What is the Big- O notation for Euclid’s Algorithm runtime?  Lecture 15:  Show f(n) = 10n + 5 is in O(n 2 )

  3. Notes  Modified Office Hours Today  Midterm  Homework Handback

  4. Lesson 14 & 15  Big – O => Upper Bound

  5. Lesson 14 & 15  Big – O => Upper Bound  f(n) = O(g(n)) if there exist positive constants c and n 0 such that f(n) <= c*g(n) for all n >= n 0

  6. Lesson 14 & 15  Big – O => Upper Bound  f(n) = O(g(n)) if there exist positive constants c and n 0 such that f(n) <= c*g(n) for all n >= n 0  Example: (http://www.fas.harvard.edu/~cscie119/lectures/sorting.pdf )  f(n) = n 2 /2 – n/2 is O(n 2 ), because n 2 /2 – n/2 <= n 2 for all n >= 0

  7. Lesson 14 & 15  Big – O => Upper Bound  f(n) = O(g(n)) if there exist positive constants c and n 0 such that f(n) <= c*g(n) for all n >= n 0  Example: (http://www.fas.harvard.edu/~cscie119/lectures/sorting.pdf )  f(n) = n 2 /2 – n/2 is O(n 2 ), because n 2 /2 – n/2 <= n 2 for all n >= 0 n o =0 c=1

  8. Lesson 14 & 15  Big – 𝛁 => Lower Bound  f(n) = O(g(n)) if there exist positive constants c and n 0 such that f(n) <= c*g(n) for all n >= n 0

  9. Lesson 14 & 15  Big – 𝛁 => Lower Bound  f(n) = 𝛻 (g(n)) if there exist positive constants c and n 0 such that f(n) <= c*g(n) for all n >= n 0  Example:  n 3 + 4n 2 = Ω(n 2 ) is 𝛁 O(n 2 ), because n 3 < n 3 + 4n 2 for all n > 0

  10. Lesson 14 & 15  Big – 𝛁 => Lower Bound  f(n) = 𝛻 (g(n)) if there exist positive constants c and n 0 such that f(n) <= c*g(n) for all n >= n 0  Example:  n 3 + 4n 2 = Ω(n 2 ) is 𝛁 O(n 2 ), because n 3 < n 3 + 4n 2 for all n > 0 c=1 n o =0

  11. Lesson 14 & 15  Big – 𝚰 => Tight Bound  f(n) = 𝛪 (g(n)) if there exists constants c 1 , c 2 , c 3 and n o such that c 1 *g(n) <= f(n) <= c 2 * g(n) for all n > n 0

  12. Lesson 14 & 15  Big – 𝚰 => Tight Bound  f(n) = 𝛪 (g(n)) if there exists constants c 1 , c 2 , c 3 and n o such that  c 1 *g(n) <= f(n) <= c 2 * g(n) for all n > n 0 Example: (http://www.fas.harvard.edu/~cscie119/lectures/sorting.pdf )   f(n) = n 2 /2 – n/2 is 𝛪 (n 2 ) because (1/4)* n 2 <= n 2 /2 – n/2 <= n 2 for all n >= 2

  13. Lesson 14 & 15  Big – 𝚰 => Tight Bound  f(n) = 𝛪 (g(n)) if there exists constants c 1 , c 2 , c 3 and n o such that  c 1 *g(n) <= f(n) <= c 2 * g(n) for all n > n 0 Example: (http://www.fas.harvard.edu/~cscie119/lectures/sorting.pdf )   f(n) = n 2 /2 – n/2 is 𝛪 (n 2 ) because (1/4)* n 2 <= n 2 /2 – n/2 <= n 2 for all n >= 2 c 1 =1/4 c 2 =1 n o = 2

  14. Lesson 14 & 15 http://bigocheatsheet.com/

  15. Homework (Group) Determine whether each of these functions is O(x) by giving a C and n 0 value where appropriate f(x) = 10 1. f(x) = 3x+7 2. f(x) = x 2 +x+1 3. f(x) = 5 log x 4. f(x) = floor(x) 5. f(x) = ceiling(x) 6.

  16. Homework (Individual) Explain the differences between Big-O, Big- Ω (Omega), and Big- Θ (Theta) 1. Explains what it means for a function to be O(1) instead of O(n) 2. Show that f(x) = (x + 5) log 2 (3x 2 + 7) is O(x log 2 x) 3. Hint: Remember that log(x k ) = k ⋅ log(x) a) Consider: f(x) = 15n 3 + n 2 + 4, 4. Express f(x) in Big - O notation a) Express f(x) in Big – Ω notation b) Express f(x) in Big – Θ notation c)

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend