CS 240: Algorithms and Data Structures
James Madison University, Fall 2024

Big-O Exercises

Definitions of Big-O, Big-Ω, Big-Θ

Big-O For T(n) a non-negative function, T(n) O(f(n)) if and only if there exist positive constants c and n0 such that T(n)cf(n) for all n>n0
Big Ω For T(n) a non-negative function, T(n) Ω(f(n)) if and only if there exist positive constants c and n0 such that T(n)cf(n) for all n>n0
Big Θ

f(n)Θ(g(n)) iff

f(n)O(g(n)) and f(n)Ω(g(n))

Limit Definitions

iflimnf(n)g(n){[0,),f(n)O(g(n))(0,),f(n)Θ(g(n))(0,],f(n)Ω(g(n))

Exercise 1

Use the non-limit definition of big-O to demonstrate that

12n2O(n2)

(This requires that you find constants c and n0 that satisfy the definition.)

Exercise 2

Determine the relationship between f(n)=10n2+3n and g(n)=n4 by finding limnf(n)g(n). Your solution must show each step of the derivation. In the end, either the numerator, the denominator, or both, must be constants.

 

Exercise 3

Determine the relationship between f(n)=log2n and g(n)=n by finding limnf(n)g(n).

Some potentially helpful reminders:

logba=logdalogdb, ddxlnx=1x, x=x12

Exercise 4

Assume we are working with an algorithm that requires T(n)=n3 steps to complete. By what factor does the running time increase if we double the input size? How does that answer change if the running time is instead T(n)=10n3?