Download as pdf or txt
Download as pdf or txt
You are on page 1of 20

Asymptotic Notation (O)

• Definition
f(n) = O(g(n)) iff there exist positive constants c and n0 such that f(n) 
cg(n) for all n, n  n0.
Asymptotic Notation (O)
Asymptotic Notation (O)
• Definition
f(n) = O(g(n)) iff there exist positive constants c and n0 such that f(n)  cg(n)
for all n, n  n0.
• Examples
• 3n+2=O(n)
• /* 3n+24n for n2 */
• 3n+3=O(n)
• /* 3n+34n for n3 */
• 100n+6=O(n)
• /* 100n+6101n for n10 */
• 10n2+4n+2=O(n2)
• /* 10n2+4n+211n2 for n5 */
• 6*2n+n2=O(2n)
• /* 6*2n+n2 7*2n for n4 */
Examples
• Complexity of c1n2+c2n and c3n
• for sufficiently large of value, c3n is faster than c1n2+c2n
• for small values of n, either could be faster
• c1=1, c2=2, c3=100 --> c1n2+c2n  c3n for n  98
• c1=1, c2=2, c3=1000 --> c1n2+c2n  c3n for n  998
• break even point
• no matter what the values of c1, c2, and c3, the n beyond which c3n is always faster than
c1n2+c2n
Asymptotic Notation
• Ω notation: asymptotic “greater than”:

 f(n)= Ω (g(n)) implies: f(n) “≥” g(n)


Asymptotic Notation (Ω-Omega)
Asymptotic Notation (Ω-Omega)
• Examples
• 3n+2= Ω(n)
• /* 3n+2≥3n for n1 */
• 3n+3= Ω(n)
• /* 3n+3 ≥ 3n for n1 */
• 100n+6= Ω(n)
• /* 100n+6 ≥ 100n for n1 */
• 10n2+4n+2= Ω(n2)
• /* 10n2+4n+2 ≥ n2 for n1 */
• 6*2n+n2= Ω(2n)
• /* 6*2n+n2 ≥ 2n for n1 */
Asymptotic Notation (Ɵ)
• The function f(n)= Ɵ(g(n)) iff there exist positive constants c1,c2, and n0 such that c1g(n)≤f(n) ≤

c2(g(n)

• The function 3n+2=Ɵ(n) as 3n+2≥3n for all n ≥ 2 and 3n+2 ≤ 4n for


all n ≥2 so c1=3, c2=4 and n0=2.
Asymptotic Notation (Ɵ)
• θ notation: asymptotic “equality”:

 f(n)= θ (g(n)) implies: f(n) “=” g(n)


Asymptotic Notation (Ɵ)

• 10n2+4n+2=Ɵ(n2)

• 6*2n+n2=Ɵ(2n)

• 10*logn+4 =Ɵ(logn)

• 3n+2? Ɵ(1)
Questions
1. Which of the following criteria is/are followed by an algorithm?
a) Definiteness
b) Effectiveness
c) Finiteness
d) All of these
Questions
1. Which of the following criteria is/are followed by an algorithm?
a) Definiteness
b) Effectiveness
c) Finiteness
d) All of these
A: d)
Questions
2. Which of the following can be used for specifying an alogirthm?
a) Plain English
b) Structured English
c) Psuedocode
d) All of these
Questions
2. Which of the following can be used for specifying an alogirthm?
a) Plain English
b) Structured English
c) Psuedocode
d) All of these
A: d
Questions
3. Which of the following asymptotic notations is used to provide an
upper bound?
a) Big-O
b) Big-Omega
c) Theta
d) None of these
Questions
3. Which of the following asymptotic notations is used to provide an
upper bound?
a) Big-O
b) Big-Omega
c) Theta
d) None of these
A: a
Questions
4. Which of the following asymptotic notations is used to provide tight
bound?
a) Big-O
b) Big-Omega
c) Theta
d) None of these
Questions
4. Which of the following asymptotic notations is used to provide tight
bound?
a) Big-O
b) Big-Omega
c) Theta
d) None of these
A: c
Questions
5. Which of the following asymptotic notations exhibits symmetry
property?
a) Big-O
b) Big-Omega
c) Theta
d) None of these
Questions
5. Which of the following asymptotic notations exhibits symmetry
property?
a) Big-O
b) Big-Omega
c) Theta
d) None of these
A: c

You might also like