SlideShare a Scribd company logo
July 13, 2025 Comp 122, Spring 2004
Asymptotic Notation,
Review of Functions &
Summations
Comp 122
ymp - 2
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
).
 Describes behavior of function in the limit.
 Written using Asymptotic Notation.
Comp 122
ymp - 3
Asymptotic Notation
 , O, , o, 
 Defined for functions over the natural numbers.
 Ex: f(n) = (n2
).
 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.
Comp 122
ymp - 4
-notation
(g(n)) = {f(n) :
 positive constants c1, c2, and n0,
such that n  n0,
we have 0  c1g(n)  f(n) 
c2g(n)
}
For function g(n), we define (g(n)),
big-Theta of n, as the set:
g(n) is an asymptotically tight bound for f(n).
Intuitively: Set of all functions that
have the same rate of growth as g(n).
Comp 122
ymp - 5
-notation
(g(n)) = {f(n) :
 positive constants c1, c2, and n0,
such that n  n0,
we have 0  c1g(n)  f(n) 
c2g(n)
}
For function g(n), we define (g(n)),
big-Theta of n, as the set:
Technically, f(n)  (g(n)).
Older usage, f(n) = (g(n)).
I’ll accept either…
f(n) and g(n) are nonnegative, for large n.
Comp 122
ymp - 6
Example
 10n2
- 3n = (n2
)
 What constants for n0, c1, and c2 will work?
 Make c1 a little smaller than the leading
coefficient, and c2 a little bigger.
 To compare orders of growth, look at the
leading term.
 Exercise: Prove that n2
/2-3n= (n2
)
(g(n)) = {f(n) :  positive constants c1, c2, and n0,
such that n  n0, 0  c1g(n)  f(n)  c2g(n)}
Comp 122
ymp - 7
Example
 Is 3n3
 (n4
) ??
 How about 22n
 (2n
)??
(g(n)) = {f(n) :  positive constants c1, c2, and n0,
such that n  n0, 0  c1g(n)  f(n)  c2g(n)}
Comp 122
ymp - 8
O-notation
O(g(n)) = {f(n) :
 positive constants c and n0,
such that n  n0,
we have 0  f(n)  cg(n) }
For function g(n), we define O(g(n)),
big-O of n, as the set:
g(n) is an asymptotic upper bound for f(n).
Intuitively: Set of all functions
whose rate of growth is the same as
or lower than that of g(n).
f(n) = (g(n))  f(n) = O(g(n)).
(g(n))  O(g(n)).
Comp 122
ymp - 9
Examples
 Any linear function an + b is in O(n2
). How?
 Show that 3n3
=O(n4
) for appropriate c and n0.
O(g(n)) = {f(n) :  positive constants c and n0,
such that n  n0, we have 0  f(n)  cg(n) }
Comp 122
ymp - 10
 -notation
g(n) is an asymptotic lower bound for f(n).
Intuitively: Set of all functions
whose rate of growth is the same
as or higher than that of g(n).
f(n) = (g(n))  f(n) = (g(n)).
(g(n))  (g(n)).
(g(n)) = {f(n) :
 positive constants c and n0,
such that n  n0,
we have 0  cg(n)  f(n)}
For function g(n), we define (g(n)),
big-Omega of n, as the set:
Comp 122
ymp - 11
Example
 n = (lg n). Choose c and n0.
(g(n)) = {f(n) :  positive constants c and n0, such
that n  n0, we have 0  cg(n)  f(n)}
Comp 122
ymp - 12
Relations Between , O, 
Comp 122
ymp - 13
Relations Between , , O
 I.e., (g(n)) = O(g(n))  (g(n))
 In practice, asymptotically tight bounds are
obtained from asymptotic upper and lower bounds.
Theorem : For any two functions g(n) and f(n),
f(n) = (g(n)) iff
f(n) = O(g(n)) and f(n) = (g(n)).
Comp 122
ymp - 14
Running Times
 “Running time is O(f(n))”  Worst case is O(f(n))
 O(f(n)) bound on the worst-case running time 
O(f(n)) bound on the running time of every input.
 (f(n)) bound on the worst-case running time 
(f(n)) bound on the running time of every input.
 “Running time is (f(n))”  Best case is (f(n))
 Can still say “Worst-case running time is (f(n))”
 Means worst-case running time is given by some
unspecified function g(n)  (f(n)).
Comp 122
ymp - 15
Example
 Insertion sort takes (n2
) in the worst case, so
sorting (as a problem) is O(n2
). Why?
 Any sort algorithm must look at each item, so
sorting is (n).
 In fact, using (e.g.) merge sort, sorting is (n lg n)
in the worst case.
 Later, we will prove that we cannot hope that any
comparison sort to do better in the worst case.
Comp 122
ymp - 16
Asymptotic Notation in Equations
 Can use asymptotic notation in equations to
replace expressions containing lower-order terms.
 For example,
4n3
+ 3n2
+ 2n + 1 = 4n3
+ 3n2
+ (n)
= 4n3
+ (n2
) = (n3
). How to interpret?
 In equations, (f(n)) always stands for an
anonymous function g(n)  (f(n))
 In the example above, (n2
) stands for
3n2
+ 2n + 1.
Comp 122
ymp - 17
o-notation
f(n) becomes insignificant relative to g(n) as n
approaches infinity:
lim [f(n) / g(n)] = 0
n
g(n) is an upper bound for f(n) that is not
asymptotically tight.
Observe the difference in this definition from previous
ones. Why?
o(g(n)) = {f(n):  c > 0,  n0 > 0 such that
 n  n0, we have 0  f(n) < cg(n)}.
For a given function g(n), the set little-o:
Comp 122
ymp - 18
(g(n)) = {f(n):  c > 0,  n0 > 0 such that
 n  n0, we have 0  cg(n) < f(n)}.
 -notation
f(n) becomes arbitrarily large relative to g(n) as n
approaches infinity:
lim [f(n) / g(n)] = .
n
g(n) is a lower bound for f(n) that is not
asymptotically tight.
For a given function g(n), the set little-omega:
Comp 122
ymp - 19
Comparison of Functions
f  g  a  b
f (n) = O(g(n))  a  b
f (n) = (g(n))  a  b
f (n) = (g(n))  a = b
f (n) = o(g(n))  a < b
f (n) = (g(n))  a > b
Comp 122
ymp - 20
Limits
 lim [f(n) / g(n)] = 0  f(n)  (g(n))
n
 lim [f(n) / g(n)] <   f(n)  (g(n))
n
 0 < lim [f(n) / g(n)] <   f(n)  (g(n))
n
 0 < lim [f(n) / g(n)]  f(n) (g(n))
n
 lim [f(n) / g(n)] =   f(n)  (g(n))
n
 lim [f(n) / g(n)] undefined can’t say
n
Comp 122
ymp - 21
Properties
 Transitivity
f(n) = (g(n)) & g(n) = (h(n))  f(n) = (h(n))
f(n) = O(g(n)) & g(n) = O(h(n))  f(n) = O(h(n))
f(n) = (g(n)) & g(n) = (h(n))  f(n) = (h(n))
f(n) = o (g(n)) & g(n) = o (h(n))  f(n) = o (h(n))
f(n) = (g(n)) & g(n) = (h(n))  f(n) = (h(n))
 Reflexivity
f(n) = (f(n))
f(n) = O(f(n))
f(n) = (f(n))
Comp 122
ymp - 22
Properties
 Symmetry
f(n) = (g(n)) iff g(n) = (f(n))
 Complementarity
f(n) = O(g(n)) iff g(n) = (f(n))
f(n) = o(g(n)) iff g(n) = ((f(n))
July 13, 2025 Comp 122, Spring 2004
Common Functions
Comp 122
ymp - 24
Monotonicity
 f(n) is
 monotonically increasing if m  n  f(m)  f(n).
 monotonically decreasing if m  n  f(m)  f(n).
 strictly increasing if m < n  f(m) < f(n).
 strictly decreasing if m > n  f(m) > f(n).
Comp 122
ymp - 25
Exponentials
 Useful Identities:
 Exponentials and polynomials
n
m
n
m
mn
n
m
a
a
a
a
a
a
a





)
(
1
1
)
(
0
lim
n
b
n
b
n
a
o
n
a
n





Comp 122
ymp - 26
Logarithms
x = logba is the
exponent for a = bx
.
Natural log: ln a = logea
Binary log: lg a = log2a
lg2
a = (lg a)2
lg lg a = lg (lg a)
a
c
a
b
b
b
c
c
b
b
n
b
c
c
c
a
b
b
b
c
a
b
a
a
a
b
a
a
a
n
a
b
a
ab
b
a
log
log
log
log
1
log
log
)
/
1
(
log
log
log
log
log
log
log
log
)
(
log









Comp 122
ymp - 27
Logarithms and exponentials – Bases
 If the base of a logarithm is changed from one
constant to another, the value is altered by a
constant factor.
 Ex: log10 n * log210 = log2 n.
 Base of logarithm is not an issue in asymptotic
notation.
 Exponentials with different bases differ by a
exponential factor (not a constant factor).
 Ex: 2n
= (2/3)n
*3n
.
Comp 122
ymp - 28
Polylogarithms
 For a  0, b > 0, lim n ( lga
n / nb
) = 0,
so lga
n = o(nb
), and nb
= (lga
n )
 Prove using L’Hopital’s rule repeatedly
 lg(n!) = (n lg n)
 Prove using Stirling’s approximation (in the text) for lg(n!).
Comp 122
ymp - 29
Exercise
Express functions in A in asymptotic notation using functions in B.
A B
5n2
+ 100n 3n2
+ 2
A  (n2
), n2
 (B)  A  (B)
log3(n2
) log2(n3
)
logba = logca / logcb; A = 2lgn / lg3, B = 3lgn, A/B =2/(3lg3)
nlg4
3lg n
alog b
=blog a
; B =3lg n
=nlg 3
; A/B =nlg(4/3)
 as n
lg2
n n1/2
lim ( lga
n / nb
) = 0 (here a = 2 and b = 1/2)  A  (B)
n
A  (B)
A  (B)
A  (B)
A  (B)
July 13, 2025 Comp 122, Spring 2004
Summations – Review
Comp 122
ymp - 31
Review on Summations
 Why do we need summation formulas?
For computing the running times of iterative
constructs (loops). (CLRS – Appendix A)
Example: Maximum Subvector
Given an array A[1…n] of numeric values (can be
positive, zero, and negative) determine the
subvector A[i…j] (1 i  j  n) whose sum of
elements is maximum over all subvectors.
1 -2 2 2
Comp 122
ymp - 32
Review on Summations
MaxSubvector(A, n)
maxsum  0;
for i  1 to n
do for j = i to n
sum  0
for k  i to j
do sum += A[k]
maxsum  max(sum, maxsum)
return maxsum
n n j
T(n) =    1
i=1 j=i k=i
NOTE: This is not a simplified solution. What is the final answer?
Comp 122
ymp - 33
Review on Summations
 Constant Series: For integers a and b, a  b,
 Linear Series (Arithmetic Series): For n  0,
 Quadratic Series: For n  0,





b
a
i
a
b 1
1
2
)
1
(
2
1
1








n
n
n
i
n
i










n
i
n
n
n
n
i
1
2
2
2
2
6
)
1
2
)(
1
(
2
1 
Comp 122
ymp - 34
Review on Summations
 Cubic Series: For n  0,
 Geometric Series: For real x  1,
For |x| < 1,








n
i
n
n
n
i
1
2
2
3
3
3
3
4
)
1
(
2
1 











n
k
n
n
k
x
x
x
x
x
x
0
1
2
1
1
1 


 

0 1
1
k
k
x
x
Comp 122
ymp - 35
Review on Summations
 Linear-Geometric Series: For n  0, real c  1,
 Harmonic Series: nth harmonic number, nI+
,














n
i
n
n
n
i
c
c
nc
c
n
nc
c
c
ic
1
2
2
1
2
)
1
(
)
1
(
2 
n
Hn
1
3
1
2
1
1 



 





n
k
O
n
k
1
)
1
(
)
ln(
1
Comp 122
ymp - 36
Review on Summations
 Telescoping Series:
 Differentiating Series: For |x| < 1,


 


n
k
n
k
k a
a
a
a
1
0
1
 


 

0
2
1
k
k
x
x
kx
Comp 122
ymp - 37
Review on Summations
 Approximation by integrals:
 For monotonically increasing f(n)
 For monotonically decreasing f(n)
 How?
  
 



n
m
n
m
k
n
m
dx
x
f
k
f
dx
x
f
1
1
)
(
)
(
)
(
  

 


1
1
)
(
)
(
)
(
n
m
n
m
k
n
m
dx
x
f
k
f
dx
x
f
Comp 122
ymp - 38
Review on Summations
 nth harmonic number
 





n
k
n
n
x
dx
k
1
1
1
)
1
ln(
1
 



n
k
n
n
x
dx
k
2 1
ln
1





n
k
n
k
1
1
ln
1
Comp 122
ymp - 39
Reading Assignment
 Chapter 4 of CLRS.

More Related Content

PPTX
Asymptotic notations for desing analysis of algorithm.pptx
PPT
02-asymp.ppt
PPT
Asymtotic Appoach.ppt
PPT
02 asymp
PDF
DAA_LECT_2.pdf
PPTX
Asymptotic notations
PPTX
Asymptotic Notation
PPT
Clase3 Notacion
Asymptotic notations for desing analysis of algorithm.pptx
02-asymp.ppt
Asymtotic Appoach.ppt
02 asymp
DAA_LECT_2.pdf
Asymptotic notations
Asymptotic Notation
Clase3 Notacion

Similar to 02-asymp.ppt01_Intro.ppt algorithm for preperation stu used (20)

PPTX
Dr hasany 2467_16649_1_lec-2-zabist
PDF
Asymptotic Notation
PDF
asymptoticnotations-111102093214-phpapp01 (1).pdf
PPTX
Asymptotic notation ada
PPTX
02 asymptotic notations
PPT
AsymptoticAnalysis-goal of analysis of algorithms
PPT
AsymptoticAnalysis.ppt
PDF
Introduction to analysis algorithm in computer Science 2
PDF
asymptomatic notations and analysis in computer science
PPT
Design and analysis of algorithm ppt ppt
PPT
Lecture 4 - Growth of Functions (1).ppt
PPT
Lecture 4 - Growth of Functions.ppt
PPT
Asymptotic analysis
PDF
CS-102 DS-class_01_02 Lectures Data .pdf
PDF
6_12_13Asymptotic analysiskfnhlkjsbfbkjs.pdf
PPTX
1_Asymptotic_Notation_pptx.pptx
PDF
Lecture 3(a) Asymptotic-analysis.pdf
PPTX
2_Asymptotic notations.pptx
PPT
Asymptotic notations
PDF
Dr hasany 2467_16649_1_lec-2-zabist
Asymptotic Notation
asymptoticnotations-111102093214-phpapp01 (1).pdf
Asymptotic notation ada
02 asymptotic notations
AsymptoticAnalysis-goal of analysis of algorithms
AsymptoticAnalysis.ppt
Introduction to analysis algorithm in computer Science 2
asymptomatic notations and analysis in computer science
Design and analysis of algorithm ppt ppt
Lecture 4 - Growth of Functions (1).ppt
Lecture 4 - Growth of Functions.ppt
Asymptotic analysis
CS-102 DS-class_01_02 Lectures Data .pdf
6_12_13Asymptotic analysiskfnhlkjsbfbkjs.pdf
1_Asymptotic_Notation_pptx.pptx
Lecture 3(a) Asymptotic-analysis.pdf
2_Asymptotic notations.pptx
Asymptotic notations
Ad

More from archu26 (6)

PDF
Book.pdf01_Intro.ppt algorithm for preperation stu used
PPTX
811109685-CS3401-Algorithms-Unit-IV.pptx
PPT
7.2 Cook's Theorem.ppt 01_Intro.ppt algorithm for preperation stu used
PPT
01_Intro.ppt algorithm for preperation stu used
PPTX
algorithm cs3401 ppt unit 3 - cover all topics
PPTX
UNIT DAA PPT cover all topics 2021 regulation
Book.pdf01_Intro.ppt algorithm for preperation stu used
811109685-CS3401-Algorithms-Unit-IV.pptx
7.2 Cook's Theorem.ppt 01_Intro.ppt algorithm for preperation stu used
01_Intro.ppt algorithm for preperation stu used
algorithm cs3401 ppt unit 3 - cover all topics
UNIT DAA PPT cover all topics 2021 regulation
Ad

Recently uploaded (20)

PPT
Machine printing techniques and plangi dyeing
PPTX
Tenders & Contracts Works _ Services Afzal.pptx
PDF
Emailing DDDX-MBCaEiB.pdf DDD_Europe_2022_Intro_to_Context_Mapping_pdf-165590...
DOCX
The story of the first moon landing.docx
PPTX
DOC-20250430-WA0014._20250714_235747_0000.pptx
PPTX
BSCS lesson 3.pptxnbbjbb mnbkjbkbbkbbkjb
PDF
Interior Structure and Construction A1 NGYANQI
PDF
High-frequency high-voltage transformer outline drawing
PDF
Key Trends in Website Development 2025 | B3AITS - Bow & 3 Arrows IT Solutions
PPT
unit 1 ppt.ppthhhhhhhhhhhhhhhhhhhhhhhhhh
PPTX
AD Bungalow Case studies Sem 2.pptxvwewev
PPTX
AC-Unit1.pptx CRYPTOGRAPHIC NNNNFOR ALL
DOCX
actividad 20% informatica microsoft project
PPTX
Fundamental Principles of Visual Graphic Design.pptx
PDF
YOW2022-BNE-MinimalViableArchitecture.pdf
PPTX
building Planning Overview for step wise design.pptx
PDF
Phone away, tabs closed: No multitasking
PDF
Wio LTE JP Version v1.3b- 4G, Cat.1, Espruino Compatible\202001935, PCBA;Wio ...
PDF
UNIT 1 Introduction fnfbbfhfhfbdhdbdto Java.pptx.pdf
PDF
Quality Control Management for RMG, Level- 4, Certificate
Machine printing techniques and plangi dyeing
Tenders & Contracts Works _ Services Afzal.pptx
Emailing DDDX-MBCaEiB.pdf DDD_Europe_2022_Intro_to_Context_Mapping_pdf-165590...
The story of the first moon landing.docx
DOC-20250430-WA0014._20250714_235747_0000.pptx
BSCS lesson 3.pptxnbbjbb mnbkjbkbbkbbkjb
Interior Structure and Construction A1 NGYANQI
High-frequency high-voltage transformer outline drawing
Key Trends in Website Development 2025 | B3AITS - Bow & 3 Arrows IT Solutions
unit 1 ppt.ppthhhhhhhhhhhhhhhhhhhhhhhhhh
AD Bungalow Case studies Sem 2.pptxvwewev
AC-Unit1.pptx CRYPTOGRAPHIC NNNNFOR ALL
actividad 20% informatica microsoft project
Fundamental Principles of Visual Graphic Design.pptx
YOW2022-BNE-MinimalViableArchitecture.pdf
building Planning Overview for step wise design.pptx
Phone away, tabs closed: No multitasking
Wio LTE JP Version v1.3b- 4G, Cat.1, Espruino Compatible\202001935, PCBA;Wio ...
UNIT 1 Introduction fnfbbfhfhfbdhdbdto Java.pptx.pdf
Quality Control Management for RMG, Level- 4, Certificate

02-asymp.ppt01_Intro.ppt algorithm for preperation stu used

  • 1. July 13, 2025 Comp 122, Spring 2004 Asymptotic Notation, Review of Functions & Summations
  • 2. Comp 122 ymp - 2 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 ).  Describes behavior of function in the limit.  Written using Asymptotic Notation.
  • 3. Comp 122 ymp - 3 Asymptotic Notation  , O, , o,   Defined for functions over the natural numbers.  Ex: f(n) = (n2 ).  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.
  • 4. Comp 122 ymp - 4 -notation (g(n)) = {f(n) :  positive constants c1, c2, and n0, such that n  n0, we have 0  c1g(n)  f(n)  c2g(n) } For function g(n), we define (g(n)), big-Theta of n, as the set: g(n) is an asymptotically tight bound for f(n). Intuitively: Set of all functions that have the same rate of growth as g(n).
  • 5. Comp 122 ymp - 5 -notation (g(n)) = {f(n) :  positive constants c1, c2, and n0, such that n  n0, we have 0  c1g(n)  f(n)  c2g(n) } For function g(n), we define (g(n)), big-Theta of n, as the set: Technically, f(n)  (g(n)). Older usage, f(n) = (g(n)). I’ll accept either… f(n) and g(n) are nonnegative, for large n.
  • 6. Comp 122 ymp - 6 Example  10n2 - 3n = (n2 )  What constants for n0, c1, and c2 will work?  Make c1 a little smaller than the leading coefficient, and c2 a little bigger.  To compare orders of growth, look at the leading term.  Exercise: Prove that n2 /2-3n= (n2 ) (g(n)) = {f(n) :  positive constants c1, c2, and n0, such that n  n0, 0  c1g(n)  f(n)  c2g(n)}
  • 7. Comp 122 ymp - 7 Example  Is 3n3  (n4 ) ??  How about 22n  (2n )?? (g(n)) = {f(n) :  positive constants c1, c2, and n0, such that n  n0, 0  c1g(n)  f(n)  c2g(n)}
  • 8. Comp 122 ymp - 8 O-notation O(g(n)) = {f(n) :  positive constants c and n0, such that n  n0, we have 0  f(n)  cg(n) } For function g(n), we define O(g(n)), big-O of n, as the set: g(n) is an asymptotic upper bound for f(n). Intuitively: Set of all functions whose rate of growth is the same as or lower than that of g(n). f(n) = (g(n))  f(n) = O(g(n)). (g(n))  O(g(n)).
  • 9. Comp 122 ymp - 9 Examples  Any linear function an + b is in O(n2 ). How?  Show that 3n3 =O(n4 ) for appropriate c and n0. O(g(n)) = {f(n) :  positive constants c and n0, such that n  n0, we have 0  f(n)  cg(n) }
  • 10. Comp 122 ymp - 10  -notation g(n) is an asymptotic lower bound for f(n). Intuitively: Set of all functions whose rate of growth is the same as or higher than that of g(n). f(n) = (g(n))  f(n) = (g(n)). (g(n))  (g(n)). (g(n)) = {f(n) :  positive constants c and n0, such that n  n0, we have 0  cg(n)  f(n)} For function g(n), we define (g(n)), big-Omega of n, as the set:
  • 11. Comp 122 ymp - 11 Example  n = (lg n). Choose c and n0. (g(n)) = {f(n) :  positive constants c and n0, such that n  n0, we have 0  cg(n)  f(n)}
  • 12. Comp 122 ymp - 12 Relations Between , O, 
  • 13. Comp 122 ymp - 13 Relations Between , , O  I.e., (g(n)) = O(g(n))  (g(n))  In practice, asymptotically tight bounds are obtained from asymptotic upper and lower bounds. Theorem : For any two functions g(n) and f(n), f(n) = (g(n)) iff f(n) = O(g(n)) and f(n) = (g(n)).
  • 14. Comp 122 ymp - 14 Running Times  “Running time is O(f(n))”  Worst case is O(f(n))  O(f(n)) bound on the worst-case running time  O(f(n)) bound on the running time of every input.  (f(n)) bound on the worst-case running time  (f(n)) bound on the running time of every input.  “Running time is (f(n))”  Best case is (f(n))  Can still say “Worst-case running time is (f(n))”  Means worst-case running time is given by some unspecified function g(n)  (f(n)).
  • 15. Comp 122 ymp - 15 Example  Insertion sort takes (n2 ) in the worst case, so sorting (as a problem) is O(n2 ). Why?  Any sort algorithm must look at each item, so sorting is (n).  In fact, using (e.g.) merge sort, sorting is (n lg n) in the worst case.  Later, we will prove that we cannot hope that any comparison sort to do better in the worst case.
  • 16. Comp 122 ymp - 16 Asymptotic Notation in Equations  Can use asymptotic notation in equations to replace expressions containing lower-order terms.  For example, 4n3 + 3n2 + 2n + 1 = 4n3 + 3n2 + (n) = 4n3 + (n2 ) = (n3 ). How to interpret?  In equations, (f(n)) always stands for an anonymous function g(n)  (f(n))  In the example above, (n2 ) stands for 3n2 + 2n + 1.
  • 17. Comp 122 ymp - 17 o-notation f(n) becomes insignificant relative to g(n) as n approaches infinity: lim [f(n) / g(n)] = 0 n g(n) is an upper bound for f(n) that is not asymptotically tight. Observe the difference in this definition from previous ones. Why? o(g(n)) = {f(n):  c > 0,  n0 > 0 such that  n  n0, we have 0  f(n) < cg(n)}. For a given function g(n), the set little-o:
  • 18. Comp 122 ymp - 18 (g(n)) = {f(n):  c > 0,  n0 > 0 such that  n  n0, we have 0  cg(n) < f(n)}.  -notation f(n) becomes arbitrarily large relative to g(n) as n approaches infinity: lim [f(n) / g(n)] = . n g(n) is a lower bound for f(n) that is not asymptotically tight. For a given function g(n), the set little-omega:
  • 19. Comp 122 ymp - 19 Comparison of Functions f  g  a  b f (n) = O(g(n))  a  b f (n) = (g(n))  a  b f (n) = (g(n))  a = b f (n) = o(g(n))  a < b f (n) = (g(n))  a > b
  • 20. Comp 122 ymp - 20 Limits  lim [f(n) / g(n)] = 0  f(n)  (g(n)) n  lim [f(n) / g(n)] <   f(n)  (g(n)) n  0 < lim [f(n) / g(n)] <   f(n)  (g(n)) n  0 < lim [f(n) / g(n)]  f(n) (g(n)) n  lim [f(n) / g(n)] =   f(n)  (g(n)) n  lim [f(n) / g(n)] undefined can’t say n
  • 21. Comp 122 ymp - 21 Properties  Transitivity f(n) = (g(n)) & g(n) = (h(n))  f(n) = (h(n)) f(n) = O(g(n)) & g(n) = O(h(n))  f(n) = O(h(n)) f(n) = (g(n)) & g(n) = (h(n))  f(n) = (h(n)) f(n) = o (g(n)) & g(n) = o (h(n))  f(n) = o (h(n)) f(n) = (g(n)) & g(n) = (h(n))  f(n) = (h(n))  Reflexivity f(n) = (f(n)) f(n) = O(f(n)) f(n) = (f(n))
  • 22. Comp 122 ymp - 22 Properties  Symmetry f(n) = (g(n)) iff g(n) = (f(n))  Complementarity f(n) = O(g(n)) iff g(n) = (f(n)) f(n) = o(g(n)) iff g(n) = ((f(n))
  • 23. July 13, 2025 Comp 122, Spring 2004 Common Functions
  • 24. Comp 122 ymp - 24 Monotonicity  f(n) is  monotonically increasing if m  n  f(m)  f(n).  monotonically decreasing if m  n  f(m)  f(n).  strictly increasing if m < n  f(m) < f(n).  strictly decreasing if m > n  f(m) > f(n).
  • 25. Comp 122 ymp - 25 Exponentials  Useful Identities:  Exponentials and polynomials n m n m mn n m a a a a a a a      ) ( 1 1 ) ( 0 lim n b n b n a o n a n     
  • 26. Comp 122 ymp - 26 Logarithms x = logba is the exponent for a = bx . Natural log: ln a = logea Binary log: lg a = log2a lg2 a = (lg a)2 lg lg a = lg (lg a) a c a b b b c c b b n b c c c a b b b c a b a a a b a a a n a b a ab b a log log log log 1 log log ) / 1 ( log log log log log log log log ) ( log         
  • 27. Comp 122 ymp - 27 Logarithms and exponentials – Bases  If the base of a logarithm is changed from one constant to another, the value is altered by a constant factor.  Ex: log10 n * log210 = log2 n.  Base of logarithm is not an issue in asymptotic notation.  Exponentials with different bases differ by a exponential factor (not a constant factor).  Ex: 2n = (2/3)n *3n .
  • 28. Comp 122 ymp - 28 Polylogarithms  For a  0, b > 0, lim n ( lga n / nb ) = 0, so lga n = o(nb ), and nb = (lga n )  Prove using L’Hopital’s rule repeatedly  lg(n!) = (n lg n)  Prove using Stirling’s approximation (in the text) for lg(n!).
  • 29. Comp 122 ymp - 29 Exercise Express functions in A in asymptotic notation using functions in B. A B 5n2 + 100n 3n2 + 2 A  (n2 ), n2  (B)  A  (B) log3(n2 ) log2(n3 ) logba = logca / logcb; A = 2lgn / lg3, B = 3lgn, A/B =2/(3lg3) nlg4 3lg n alog b =blog a ; B =3lg n =nlg 3 ; A/B =nlg(4/3)  as n lg2 n n1/2 lim ( lga n / nb ) = 0 (here a = 2 and b = 1/2)  A  (B) n A  (B) A  (B) A  (B) A  (B)
  • 30. July 13, 2025 Comp 122, Spring 2004 Summations – Review
  • 31. Comp 122 ymp - 31 Review on Summations  Why do we need summation formulas? For computing the running times of iterative constructs (loops). (CLRS – Appendix A) Example: Maximum Subvector Given an array A[1…n] of numeric values (can be positive, zero, and negative) determine the subvector A[i…j] (1 i  j  n) whose sum of elements is maximum over all subvectors. 1 -2 2 2
  • 32. Comp 122 ymp - 32 Review on Summations MaxSubvector(A, n) maxsum  0; for i  1 to n do for j = i to n sum  0 for k  i to j do sum += A[k] maxsum  max(sum, maxsum) return maxsum n n j T(n) =    1 i=1 j=i k=i NOTE: This is not a simplified solution. What is the final answer?
  • 33. Comp 122 ymp - 33 Review on Summations  Constant Series: For integers a and b, a  b,  Linear Series (Arithmetic Series): For n  0,  Quadratic Series: For n  0,      b a i a b 1 1 2 ) 1 ( 2 1 1         n n n i n i           n i n n n n i 1 2 2 2 2 6 ) 1 2 )( 1 ( 2 1 
  • 34. Comp 122 ymp - 34 Review on Summations  Cubic Series: For n  0,  Geometric Series: For real x  1, For |x| < 1,         n i n n n i 1 2 2 3 3 3 3 4 ) 1 ( 2 1             n k n n k x x x x x x 0 1 2 1 1 1       0 1 1 k k x x
  • 35. Comp 122 ymp - 35 Review on Summations  Linear-Geometric Series: For n  0, real c  1,  Harmonic Series: nth harmonic number, nI+ ,               n i n n n i c c nc c n nc c c ic 1 2 2 1 2 ) 1 ( ) 1 ( 2  n Hn 1 3 1 2 1 1            n k O n k 1 ) 1 ( ) ln( 1
  • 36. Comp 122 ymp - 36 Review on Summations  Telescoping Series:  Differentiating Series: For |x| < 1,       n k n k k a a a a 1 0 1        0 2 1 k k x x kx
  • 37. Comp 122 ymp - 37 Review on Summations  Approximation by integrals:  For monotonically increasing f(n)  For monotonically decreasing f(n)  How?         n m n m k n m dx x f k f dx x f 1 1 ) ( ) ( ) (         1 1 ) ( ) ( ) ( n m n m k n m dx x f k f dx x f
  • 38. Comp 122 ymp - 38 Review on Summations  nth harmonic number        n k n n x dx k 1 1 1 ) 1 ln( 1      n k n n x dx k 2 1 ln 1      n k n k 1 1 ln 1
  • 39. Comp 122 ymp - 39 Reading Assignment  Chapter 4 of CLRS.