0% found this document useful (0 votes)
21 views14 pages

Mathematical Notation - Big Oh, Omega and Theta

Introduction to Asymptotic Notations - Big Oh, Big Omega and Theta

Uploaded by

saady
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
21 views14 pages

Mathematical Notation - Big Oh, Omega and Theta

Introduction to Asymptotic Notations - Big Oh, Big Omega and Theta

Uploaded by

saady
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 14

Mathematical Notation - Big Oh,

Omega and Theta


By
Dr. Saad Yunus Sait
Order of Growth of Algorithms

*Chart from Medium.com


Order of Growth Vs Constant Processing Time

Algorithm DoSomething(…)
begin
x = f(input size);
for i := 1 to x do
Do_processing(); /* Each execution takes C time*/
end /* DoSomething */

Time complexity = C.f(n)


Comparison of Performance of n² with 2ⁿ
Consider
f(n) = 10⁶ x n²
g(n) = 2 x 2ⁿ

For n = 10
f(10) = 10⁶ x 0.01 = 10⁴ secs
g(10) = 2 x 0.1024 = 0.205 secs
So, g(n) = 2 x 2ⁿ provides better performance than f(n) = 10⁶ x n² for n = 10

For n = 50
f(50) = 10⁶ x 0.25 = 250,000 secs
g(50) = 2 x 35.702 = 71.4 cen
So, f(n) = 10⁶ x n² beat g(n) = 2 x 2ⁿ
even for a small input of n = 50 despite the large constant of 10⁶ in f(n)

Order of growth overwhelms any differences in constants.


Important Points Regarding Order of Growth
● na grows faster than nb if a > b for a, b ∈ R
○ n5 grows faster than n4, n3, n2 etc.
○ n grows faster than n0.5, n0.33 etc.
○ n-1 is slower than n0 = 1
● lg n grows faster than constant time (n0) but is slower than na for any a>0
○ lg n grows slower than even n0.001
○ (lg n)a also written as lga n grows faster than lg n for a > 1
● If f(n) grows faster than g(n), then for any function h(n), f(n)h(n) grows faster
than g(n)h(n)
○ n2 grows faster than n lg n
○ n lg n grows faster than lg2 n
Asymptotic Notations

● Formal way to describe / compare order of growth

● Indicate which function grows faster / performs better

● Interest is in the performance for large values of n (→∞)

● Constants don’t make a difference


Asymptotic Notations - Big Oh Notation
A function f(n) is said to belong to O(g(n)) if there exist positive constants c, n₀
such that f(n) ≤ c.g(n) for all n ≥ n₀

*Figure from
Medium.com
(Alejandro Ito
Aramendia)
Points to Note Regarding Big-Oh Notation
● Provides an asymptotic upper bound for the order of growth
○ If g(n) has higher or same order of growth as f(n) than f(n) = O(g(n))

● For example
○ nb = O(na) for a ≥ b
○ lg n = O(na) for a > 0
○ lg n = O(lga n) for a ≥ 1
○ n lg n = O(n2)

● Note that n2 = O(n2), lg n = O(lg n) etc.


Big Omega Notation (Ω)
A function f(n) is said to belong to Ω(g(n)) if there exist positive constants c, n₀
such that 0 ≤ c.g(n) ≤ f(n) for all n ≥ n₀

*Figure from
geeksforgeeks.org
Points to Note Regarding Big-Omega Notation

● Provides an asymptotic lower bound for the order of growth


○ If g(n) has lower or same order of growth as f(n) than f(n) = Ω(g(n))

● For example
○ nb = Ω(na) for b ≥ a
○ na = Ω(lg n) for a > 0
○ lga n = Ω(lg n) for a ≥ 1
○ n2 = Ω(n lg n)

● Note that n2 = Ω(n2), lg n = Ω(lg n) etc.


Theta Notation (Θ)
A function f(n) is said to belong to Θ(g(n)) if there exist positive constants c1, c2, n₀
such that 0 ≤ c1.g(n) ≤ f(n) ≤ c2.g(n) for all n ≥ n₀

*Figure from
geeksforgeeks.org
Points to Note Regarding Theta Notation

● Provides an asymptotic tight bound for the order of growth


○ If g(n) has same order of growth as f(n) then f(n) = Θ(g(n))

● For example
○ nb = Θ(na) only for b = a
○ lg n ≠ Θ(na) for any a ∈ R
○ lg n = Θ(lga n) only for a = 1
○ n lg n ≠ Θ(n2)
Example 1
Prove that n2 + 2n + 3 ∈ O(n2)

Proof

n2 + 2n + 3 ≤ n2 + 2n2 + 3n2 = 6n2 for n ≥ 1

So,

n2 + 2n + 3 ≤ 6n2 for n ≥ 1, c = 6 and n0 = 1

⇒ n2 + 2n + 3 ∈ O(n2)
Example 2
Prove that n2 + 4n + 5 ∈ Ω(n2)

Proof

n2 + 4n + 5 ≥ 1.n2 ≥ 0 for n ≥ 1, put c = 1 and n0 = 1

⇒ n2 + 4n + 5 ∈ Ω(n2)

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy