0% found this document useful (0 votes)
8 views

CS460 Notes

Algorithms

Uploaded by

sherwin5634
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views

CS460 Notes

Algorithms

Uploaded by

sherwin5634
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

CS460 Algorithm Notes

Sherwin Fernandes
September 10, 2024

1
1 Big O Rules
1.1 Big O Definition
By definition,
f(n) is O(g(n)) iff ∃ (there exists) c1 , n0 > 0 where f(n) ≤ c ∗ g(n) ∀ n ≥ n0

1.2 Properties of Big O + Proofs


1. Any constant is O(1)
11. Big O is additive
By defintion of Big O,
f1 (n) ≤ c1 ∗ g1 (n) ∀ n ≥ n0
f2 (n) ≤ c2 ∗ g2 (n) ∀ n ≥ n1

If we combine them together,


f1 (n) + f2 (n) ≤ c1 ∗ g1 (n) + c2 ∗ g2 (n) ∀ n ≥ max(n0 , n1 )

Now attempt to match the Big O Rule by saying,


f1 (n) + f2 (n) ≤ max(c1 , c2 ) ∗ g1 (n) + g2 (n) ∀ n ≥ max(n0 , n1 )

1.3 Trying proof examples



1. Given f(n) = n + log(n) and g(n) = n, prove if: (only main steps given,
dive into each step + where it comes from)
if f(n) is O(g(n))
if f(n) is O(f(n))
both
none

Trying option A:
Knowing Big O equation:
√ f(n) ≤ c1 ∗ g(n) for some n ≥ n0
n + log(n) ≤ c * n for some n ≥ n0

Going to option B:
prove g(n) is O(f(n)), prove g(n) ≤ c ∗ f (n) ∀ n ≥ n0
To √
so n ≤ c ∗ (n + log(n)) ∀ n ≥ n0
substituting c = 1, n0 = 1 the equality would be valid

Therefore, g(n) is O(f(n))

1.4 Familiar with the bounds


ˆ Big O is the upper bound

ˆ Big Omega is the lower bound

2
ˆ Big Theta is the tightest bound (avg)

2 Big Omega Rules


2.1 Big Omega Definition
By definition,
f(n) is Ω(g(n)) iff ∃ c, n0 | f(n) ≥ c ∗ g(n)∀n ≥ n0

3 Big Theta Rules


3.1 Big Theta Definition
By definition,
f(n) is Θ(g(n)) iff ∃ c1 , c2 | f(n) ≤ c1 ∗ g(n) and f (n) ≥ c2 ∗ g(n) ∀ n ≥ n0
This means f(n) is Θ(g(n)) and f(n) is Ω(g(n))

You might also like