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

Asymptotic Notations

This document discusses asymptotic notations - Big O(O), Big Omega (Ω), and Theta (Θ) - which are used to describe the limiting behavior of algorithms' running times as the input size increases. It defines each notation precisely and provides examples to illustrate how to determine if one function is asymptotically bounded above or below by another. Specifically, it shows examples proving that 2n^2 is O(n^3), 5n^2 is Ω(n), and 2n^2 - 5n + 10 is Θ(n^2). The document explains that these notations allow describing an algorithm's growth rate without specifying its exact running time.

Uploaded by

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

Asymptotic Notations

This document discusses asymptotic notations - Big O(O), Big Omega (Ω), and Theta (Θ) - which are used to describe the limiting behavior of algorithms' running times as the input size increases. It defines each notation precisely and provides examples to illustrate how to determine if one function is asymptotically bounded above or below by another. Specifically, it shows examples proving that 2n^2 is O(n^3), 5n^2 is Ω(n), and 2n^2 - 5n + 10 is Θ(n^2). The document explains that these notations allow describing an algorithm's growth rate without specifying its exact running time.

Uploaded by

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

ASYMPTOTIC

NOTATIONS
Understanding Algorithms Efficiency
Team

Muhammad Usman Muneeb Anwar Bilal Ahmed


FA21-BCS-020 FA21-BCS-008 FA21-BCS-014

Asymptotic Notations 2
Asymptotic Notations
 Big Oh (O)
Agenda  Big Omega (Ω)
 Theta (Θ)

Asymptotic Notations 3
Asymptotic Complexity
 Running time of an algorithm as a function
of input size n for large n.
 Expressed using only the highest-order
term in the expression for the exact
running time.
 Instead of exact running time, say Θ(n2).
 Written using Asymptotic Notation.

Asymptotic Notations 4
Asymptotic Notations
 Θ , Ω, O, o, ω
 Defined for functions over the natural numbers.
o Ex: f(n) = O(n2).
o Describes how f(n) grows in comparison to n2.

 Define a set of functions; in practice used to


compare two function sizes.
 The notations describe different rate-of-growth
relations between the defining function and the
defined set of functions.

Asymptotic Notations 5
Algorithm
Growth Rate

Asymptotic Notations 6
Big Oh
(0)
Big-oh Notation (O)
If f, g: N → R+, then we can define Big-Oh as
For a given function g(n), denoted by O(g(n)) the set of functions,
 O(g(n)) = {f(n): there exist positive constants c and n o such that
0≤ f(n) ≤ cg(n), for all n ≥ no}
 f(n) = O(g(n)) means functions g(n) is an asymptotically upper
bound for f(n).
 We may write f(n) = O(g(n)) OR f(n) ∈ O(g(n))
Big-oh Notation (O)
f(n) =
Example 2n + n log n O(2 )
n
Example
Prove that 2n2 ∈ O(n3)
Assume that f(n) = 2n2, and g(n) = n3
f(n) ∈ O(g(n))?
Now we must find the existence of c and n0 f(n) ≤ cg(n)
2n2 ≤ c.n3
2 ≤ c.n
if we take, c = 1 and n0= 2 OR c = 2 and n0= 1 then 2n2 ≤ c.n3 Hence
f(n) ∈ O(g(n)), c = 1 and n0= 2
Example n f(n) = 2n2 g(n) = n3

Prove that 1

2
2

8
1

2n ∈ O(n )
2 3 3 18 27

4 32 64

5 50 125

6 72 216

Asymptotic Notations 12
Big Omega
(Ω)
Big-omega Notation (Ω)
If f, g: N → R+, then we can define Big-omega as
For a given function g(n), denoted by Ω(g(n)) the set of functions,
 Ω(g(n)) = {f(n): there exist positive constants c and n o such that
0≤ cg(n) ≤ f(n), for all n ≥ no}
 f(n) = Ω(g(n)) means functions g(n) is an asymptotically lower
bound for f(n).
 We may write f(n) = Ω(g(n)) OR f(n) ∈ Ω(g(n))
Big-omega Notation (Ω)
f(n) =
Example 2n + n log n Ω(nlogn)
Example
Prove that 5n2 ∈ Ω(n)
Assume that f(n) = 5n2, and g(n) = n
f(n) ∈ Ω(g(n))?
Now we must find the existence of c and n0 cg(n) ≤ f(n)
c.n ≤ 5n2
c ≤ 5n
if we take, c = 5 and n0= 1 then 5n2 ≤ c.n Hence f(n) ∈ O(g(n)), c =5
and n0= 1
Example n f(n) = 5n2 g(n) = n

Prove that 1

2
5

20
1

5n ∈ Ω(n)
2 3 45 3

4 80 4

5 125 5

6 180 6

Asymptotic Notations 18
Theta
(Θ)
Theta Notation (Θ)
If f, g: N → R+, then we can define theta as
For a given function g(n), denoted by Θ(g(n)) the set of functions,
 Θ(g(n)) = {f(n): there exist positive constants c 1, c2 and no such that
0≤ c1g(n) ≤ f(n) ≤ c2g(n) , for all n ≥ no}
 f(n) = Θ(g(n)) means functions f(n) is equal to g(n) to within a
constant factor, and g(n)is an asymptotically tight bound for f(n).
 We may write f(n) = Θ(g(n)) OR f(n) ∈ Θ(g(n))
Theta Notation (Θ)
Example
Prove that 2n2 – 5n + 10 ∈ Θ(n2)
Assume that f(n) = 2n2 – 5n + 10 , and g(n) = n2
f(n) ∈ Θ(g(n))?
Now we must find the existence of c1, c2 and n0 c1g(n)
≤ f(n) ≤ c2g(n)
if we take, c1 = 1, c2 = 2 and n0= 2 then c1n2 ≤ 2n2 – 5n + 10 ≤ c2n2
 Hence f(n) ∈ Θ(g(n)), c1 = 1, c2 = 2 and n0= 2
Example
Prove that 2n2 – 5n + 10 ∈ Θ(n2)

n f(n) = 2n2 – 5n + g(n) = n2 C1 g(n) C2 g(n)


10
1 7 1 1 2
2 8 4 4 8
3 13 9 9 18
4 22 16 16 32
5 35 25 25 50
Asymptotic Notations 23
Thank you ANY QUESTIONS ?

Asymptotic Notations 24

You might also like