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

csci 246 class 8
SMART_READER_LITE
LIVE PREVIEW

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


slide-1
SLIDE 1

CSCI 246 – Class 8

ASYMPTOTIC NOTATION

slide-2
SLIDE 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(n2)

slide-3
SLIDE 3

Notes

 Modified Office Hours Today  Midterm  Homework Handback

slide-4
SLIDE 4

Lesson 14 & 15

 Big – O => Upper Bound

slide-5
SLIDE 5

Lesson 14 & 15

 Big – O => Upper Bound  f(n) = O(g(n)) if there exist positive constants c and n0 such that

f(n) <= c*g(n) for all n >= n0

slide-6
SLIDE 6

Lesson 14 & 15

 Big – O => Upper Bound  f(n) = O(g(n)) if there exist positive constants c and n0 such that

f(n) <= c*g(n) for all n >= n0

 Example: (http://www.fas.harvard.edu/~cscie119/lectures/sorting.pdf )  f(n) = n2/2 – n/2 is O(n2), because n2/2 – n/2 <= n2 for all n >= 0

slide-7
SLIDE 7

Lesson 14 & 15

 Big – O => Upper Bound  f(n) = O(g(n)) if there exist positive constants c and n0 such that

f(n) <= c*g(n) for all n >= n0

 Example: (http://www.fas.harvard.edu/~cscie119/lectures/sorting.pdf )  f(n) = n2/2 – n/2 is O(n2), because n2/2 – n/2 <= n2 for all n >= 0

c=1 no=0

slide-8
SLIDE 8

Lesson 14 & 15

 Big – 𝛁 => Lower Bound  f(n) = O(g(n)) if there exist positive constants c and n0 such that

f(n) <= c*g(n) for all n >= n0

slide-9
SLIDE 9

Lesson 14 & 15

 Big – 𝛁 => Lower Bound  f(n) = 𝛻(g(n)) if there exist positive constants c and n0 such that

f(n) <= c*g(n) for all n >= n0

 Example:  n3 + 4n2 = Ω(n2) is 𝛁 O(n2), because n3 < n3 + 4n2 for all n > 0

slide-10
SLIDE 10

Lesson 14 & 15

 Big – 𝛁 => Lower Bound  f(n) = 𝛻(g(n)) if there exist positive constants c and n0 such that

f(n) <= c*g(n) for all n >= n0

 Example:  n3 + 4n2 = Ω(n2) is 𝛁 O(n2), because n3 < n3 + 4n2 for all n > 0

c=1 no=0

slide-11
SLIDE 11

Lesson 14 & 15

 Big – 𝚰 => Tight Bound

 f(n) = 𝛪(g(n)) if there exists constants c1, c2, c3 and no such that

c1*g(n) <= f(n) <= c2 * g(n) for all n > n0

slide-12
SLIDE 12

Lesson 14 & 15

 Big – 𝚰 => Tight Bound  f(n) = 𝛪(g(n)) if there exists constants c1, c2, c3 and no such that

 c1*g(n) <= f(n) <= c2 * g(n) for all n > n0 

Example: (http://www.fas.harvard.edu/~cscie119/lectures/sorting.pdf )

 f(n) = n2/2 – n/2 is 𝛪(n2) because (1/4)* n2 <= n2/2 – n/2 <= n2 for all n >= 2

slide-13
SLIDE 13

Lesson 14 & 15

 Big – 𝚰 => Tight Bound  f(n) = 𝛪(g(n)) if there exists constants c1, c2, c3 and no such that

 c1*g(n) <= f(n) <= c2 * g(n) for all n > n0 

Example: (http://www.fas.harvard.edu/~cscie119/lectures/sorting.pdf )

 f(n) = n2/2 – n/2 is 𝛪(n2) because (1/4)* n2 <= n2/2 – n/2 <= n2 for all n >= 2

c2=1 no = 2 c1=1/4

slide-14
SLIDE 14

Lesson 14 & 15

http://bigocheatsheet.com/

slide-15
SLIDE 15

Homework (Group)

Determine whether each of these functions is O(x) by giving a C and n0 value where appropriate

1.

f(x) = 10

2.

f(x) = 3x+7

3.

f(x) = x2+x+1

4.

f(x) = 5 log x

5.

f(x) = floor(x)

6.

f(x) = ceiling(x)

slide-16
SLIDE 16

Homework (Individual)

1.

Explain the differences between Big-O, Big-Ω (Omega), and Big-Θ (Theta)

2.

Explains what it means for a function to be O(1) instead of O(n)

3.

Show that f(x) = (x + 5) log2 (3x2 + 7) is O(x log2 x)

a)

Hint: Remember that log(xk) = k⋅log(x)

4.

Consider: f(x) = 15n3 + n2 + 4,

a)

Express f(x) in Big - O notation

b)

Express f(x) in Big – Ω notation

c)

Express f(x) in Big – Θ notation