SlideShare ist ein Scribd-Unternehmen logo
1 von 39
Asymptotic Notation,
Asymptotic Notation,
Review of Functions &
Review of Functions &
Summations
Summations

December 20, 2013

Comp 122, Spring 2004
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.

ymp - 2

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
Θ-notation
For function g(n), we define Θ(g(n)),
big-Theta of n, as the set:
Θ(g(n)) = {f(n) :
∃ positive constants c1, c2, and n0,
such that ∀n ≄ n0,
we have 0 ≀ c1g(n) ≀ f(n) ≀ c2g(n)

}
Intuitively: Set of all functions that
have the same rate of growth as g(n).

g(n) is an asymptotically tight bound for f(n).

ymp - 4

Comp 122
Θ-notation
For function g(n), we define Θ(g(n)),
big-Theta of n, as the set:
Θ(g(n)) = {f(n) :
∃ positive constants c1, c2, and n0,
such that ∀n ≄ n0,
we have 0 ≀ c1g(n) ≀ f(n) ≀ c2g(n)

}
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.
ymp - 5
Comp 122
ymp - 6

Example
Θ(g(n)) = {f(n) : ∃ positive constants c1, c2, and n0,
such that ∀n ≄ n0, 0 ≀ c1g(n) ≀ f(n) ≀ c2g(n)}

 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)
Comp 122
ymp - 7

Example
Θ(g(n)) = {f(n) : ∃ positive constants c1, c2, and n0,
such that ∀n ≄ n0, 0 ≀ c1g(n) ≀ f(n) ≀ c2g(n)}

 Is 3n3 ∈ Θ(n4) ??
 How about 22n∈ Θ(2n)??

Comp 122
O-notation
For function g(n), we define O(g(n)),
big-O of n, as the set:
O(g(n)) = {f(n) :
∃ positive constants c and n0,
such that ∀n ≄ n0,
we have 0 ≀ f(n) ≀ cg(n) }

Intuitively: Set of all functions
whose rate of growth is the same as
or lower than that of g(n).

g(n) is an asymptotic upper bound for f(n).

f(n) = Θ(g(n)) ⇒ f(n) = O(g(n)).
Θ(g(n)) ⊂ O(g(n)).
ymp - 8
Comp 122
Examples
O(g(n)) = {f(n) : ∃ positive constants c and n0,
such that ∀n ≄ n0, we have 0 ≀ f(n) ≀ cg(n) }

 Any linear function an + b is in O(n2). How?
 Show that 3n3=O(n4) for appropriate c and n0.

ymp - 9

Comp 122
℩ -notation
For function g(n), we define ℩(g(n)),
big-Omega of n, as the set:
℩(g(n)) = {f(n) :
∃ positive constants c and n0,
such that ∀n ≄ n0,
we have 0 ≀ cg(n) ≀ f(n)}

Intuitively: Set of all functions
whose rate of growth is the same
as or higher than that of g(n).

g(n) is an asymptotic lower bound for f(n).

ymp - 10

f(n) = Θ(g(n)) ⇒ f(n) = ℩(g(n)).
Θ(g(n)) ⊂ ℩(g(n)).
Comp 122
Example
℩(g(n)) = {f(n) : ∃ positive constants c and n0, such
that ∀n ≄ n0, we have 0 ≀ cg(n) ≀ f(n)}

 √n = ℩(lg n). Choose c and n0.

ymp - 11

Comp 122
ymp - 12

Relations Between Θ, O, ℩

Comp 122
Relations Between Θ, ℩, O
Theorem :: For any two functions g(n) and f(n),
Theorem For any two functions g(n) and f(n),
f(n) = Θ(g(n)) iff
f(n) = Θ(g(n)) iff
f(n) = O(g(n)) and f(n) = ℩(g(n)).
f(n) = O(g(n)) and f(n) = ℩(g(n)).

 I.e., Θ(g(n)) = O(g(n)) ∩ ℩(g(n))
 In practice, asymptotically tight bounds are
obtained from asymptotic upper and lower bounds.

ymp - 13

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
o-notation
For a given function g(n), the set little-o:
o(g(n)) = {f(n): ∀ c > 0, ∃ n0 > 0 such that
∀ n ≄ n0, we have 0 ≀ f(n) < cg(n)}.
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?

ymp - 17

Comp 122
ω -notation
For a given function g(n), the set little-omega:

ω(g(n)) = {f(n): ∀ c > 0, ∃ n

> 0 such that
∀ n ≄ n0, we have 0 ≀ cg(n) < f(n)}.
0

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.

ymp - 18

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))

Comp 122
Common Functions

December 20, 2013

Comp 122, Spring 2004
Monotonicity
 f(n) is

ymp - 24

ïł
ïł
ïł
ïł

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
Exponentials
 Useful Identities:
1
a =
a
(a m ) n = a mn
−1

a m a n = a m+ n

 Exponentials and polynomials

ymp - 25

nb
lim n = 0
n→∞ a
⇒ n b = o( a n )
Comp 122
Logarithms
x = logba is the
exponent for a = bx.

a = b logb a
log c (ab) = log c a + log c b
log b a = n log b a
n

Natural log: ln a = logea
Binary log: lg a = log2a

lg2a = (lg a)2
lg lg a = lg (lg a)

ymp - 26

log c a
log b a =
log c b
log b (1 / a ) = − log b a
1
log b a =
log a b
a logb c = c logb a
Comp 122
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).

ymp - 27

ïł Ex: 2n = (2/3)n*3n.
Comp 122
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)

ymp - 28

ïł Prove using Stirling’s approximation (in the text) for lg(n!).

Comp 122
Exercise
Express functions in A in asymptotic notation using functions in B.

ymp - 29

A
5n2 + 100n

B
3n2 + 2

A ∈ Θ(B)

A ∈ Θ(n2), n2 ∈ Θ(B) ⇒ A ∈ Θ(B)

log3(n2)

log2(n3)

A ∈ Θ(B)

logba = logca / logcb; A = 2lgn / lg3, B = 3lgn, A/B =2/(3lg3)
A ∈ ω (B)
nlg4
3lg n
alog b = blog a; B =3lg n=nlg 3; A/B =nlg(4/3) → ∞ as n→∞
A ∈ ο (B)
lg2n
n1/2
lim ( lga n / nb ) = 0 (here a = 2 and b = 1/2) ⇒ A ∈ ο (B)
n→∞

Comp 122
Summations – Review

December 20, 2013

Comp 122, Spring 2004
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
Comp 122

2
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?

ymp - 32

Comp 122
Review on Summations
 Constant Series: For integers a and b, a ≀ b,
b

∑1 = b − a + 1
i =a

 Linear Series (Arithmetic Series): For n ≄ 0,
n
n(n + 1)
∑ i = 1 + 2 + + n = 2
i =1
n
 Quadratic Series: For n 2≄ 0, 2 n(n + 1)(2n + 1)
i 2 = 12 + 2 +  + n =

ymp - 33

∑

6

i =1

Comp 122
ymp - 34

Review on Summations
 Cubic Series: For n ≄ 0,
n 2 (n + 1) 2
i 3 = 13 + 23 +  + n 3 =
∑
4
i =1
n

 Geometric Series: For real x ≠ 1,

x n+1 − 1
xk = 1+ x + x2 +  + xn =
∑
x −1
k =0
n

For |x| < 1,

∞

1
∑ x = 1− x
k =0
k

Comp 122
ymp - 35

Review on Summations
 Linear-Geometric Series: For n ≄ 0, real c ≠ 1,
n +1

− (n + 1)c + nc
∑ ic = c + 2c +  + nc =
(c − 1) 2
i =1
n

i

2

n

 Harmonic Series: nth harmonic number, n∈I+,
1 1
1
Hn = 1+ + ++
2 3
n
n

1
= ∑ = ln(n) + O(1)
k =1 k
Comp 122

n+ 2

+c
Review on Summations
 Telescoping Series:
n

∑a
k =1

k

− ak −1 = an − a0

 Differentiating Series: For |x| < 1,

ymp - 36

∞

x
∑ kx = (1 − x ) 2
k =0
k

Comp 122
Review on Summations
 Approximation by integrals:
ïł For monotonically increasing f(n)
n

∫

m−1

n

n +1

k =m

m

f ( x)dx ≀ ∑ f (k ) ≀

∫ f ( x)dx

ïł For monotonically decreasing f(n)
n +1

∫

m

n

f ( x)dx ≀ ∑ f (k ) ≀
k =m

n

∫ f ( x)dx

m−1

 How?

ymp - 37

Comp 122
Review on Summations
 nth harmonic number

ymp - 38

n

1
∑k ≄
k =1

n+1

∫
1

dx
= ln(n + 1)
x

n

n

1
dx
≀ ∫ = ln n
∑k x
k =2
1
n

1
⇒ ∑ ≀ ln n + 1
k =1 k

Comp 122
Reading Assignment
 Chapter 4 of CLRS.

ymp - 39

Comp 122

Weitere Àhnliche Inhalte

Was ist angesagt?

Asymptotic Notation and Complexity
Asymptotic Notation and ComplexityAsymptotic Notation and Complexity
Asymptotic Notation and ComplexityRajandeep Gill
 
Asymptotic notations
Asymptotic notationsAsymptotic notations
Asymptotic notationsNikhil Sharma
 
Asymptotic notations
Asymptotic notationsAsymptotic notations
Asymptotic notationsEhtisham Ali
 
Time complexity
Time complexityTime complexity
Time complexityKatang Isip
 
Asymptotic Notations
Asymptotic NotationsAsymptotic Notations
Asymptotic NotationsRishabh Soni
 
Basics & asymptotic notations
Basics & asymptotic notationsBasics & asymptotic notations
Basics & asymptotic notationsRajendran
 
Recurrences
RecurrencesRecurrences
RecurrencesDEVTYPE
 
Clase3 Notacion
Clase3 NotacionClase3 Notacion
Clase3 Notacionluzenith_g
 
Algorithm.ppt
Algorithm.pptAlgorithm.ppt
Algorithm.pptTareq Hasan
 
Asymptotic notations(Big O, Omega, Theta )
Asymptotic notations(Big O, Omega, Theta )Asymptotic notations(Big O, Omega, Theta )
Asymptotic notations(Big O, Omega, Theta )swapnac12
 
Lec03 04-time complexity
Lec03 04-time complexityLec03 04-time complexity
Lec03 04-time complexityAbbas Ali
 
RECURRENCE EQUATIONS & ANALYZING THEM
RECURRENCE EQUATIONS & ANALYZING THEMRECURRENCE EQUATIONS & ANALYZING THEM
RECURRENCE EQUATIONS & ANALYZING THEMAlpana Ingale
 

Was ist angesagt? (19)

Asymptotic Notation and Complexity
Asymptotic Notation and ComplexityAsymptotic Notation and Complexity
Asymptotic Notation and Complexity
 
Asymptotic notations
Asymptotic notationsAsymptotic notations
Asymptotic notations
 
Asymptotic notations
Asymptotic notationsAsymptotic notations
Asymptotic notations
 
Time complexity
Time complexityTime complexity
Time complexity
 
Time complexity
Time complexityTime complexity
Time complexity
 
Asymptotic Notations
Asymptotic NotationsAsymptotic Notations
Asymptotic Notations
 
Basics & asymptotic notations
Basics & asymptotic notationsBasics & asymptotic notations
Basics & asymptotic notations
 
Recurrences
RecurrencesRecurrences
Recurrences
 
Clase3 Notacion
Clase3 NotacionClase3 Notacion
Clase3 Notacion
 
Asymptotic Notation
Asymptotic NotationAsymptotic Notation
Asymptotic Notation
 
Algorithum Analysis
Algorithum AnalysisAlgorithum Analysis
Algorithum Analysis
 
Algorithm.ppt
Algorithm.pptAlgorithm.ppt
Algorithm.ppt
 
Asymptotic notations(Big O, Omega, Theta )
Asymptotic notations(Big O, Omega, Theta )Asymptotic notations(Big O, Omega, Theta )
Asymptotic notations(Big O, Omega, Theta )
 
Slide2
Slide2Slide2
Slide2
 
Recurrences
RecurrencesRecurrences
Recurrences
 
Lec03 04-time complexity
Lec03 04-time complexityLec03 04-time complexity
Lec03 04-time complexity
 
RECURRENCE EQUATIONS & ANALYZING THEM
RECURRENCE EQUATIONS & ANALYZING THEMRECURRENCE EQUATIONS & ANALYZING THEM
RECURRENCE EQUATIONS & ANALYZING THEM
 
Computational Complexity
Computational ComplexityComputational Complexity
Computational Complexity
 
Recurrences
RecurrencesRecurrences
Recurrences
 

Andere mochten auch

Lec2 Algorth
Lec2 AlgorthLec2 Algorth
Lec2 Algorthhumanist3
 
Lecture1
Lecture1Lecture1
Lecture1tarikh007
 
CS Fundamentals: Scalability and Memory
CS Fundamentals: Scalability and MemoryCS Fundamentals: Scalability and Memory
CS Fundamentals: Scalability and MemoryHaseeb Qureshi
 
how to calclute time complexity of algortihm
how to calclute time complexity of algortihmhow to calclute time complexity of algortihm
how to calclute time complexity of algortihmSajid Marwat
 
Asymptotic Notation and Data Structures
Asymptotic Notation and Data StructuresAsymptotic Notation and Data Structures
Asymptotic Notation and Data StructuresAmrinder Arora
 
Complexity of Algorithm
Complexity of AlgorithmComplexity of Algorithm
Complexity of AlgorithmMuhammad Muzammal
 
Time and space complexity
Time and space complexityTime and space complexity
Time and space complexityAnkit Katiyar
 

Andere mochten auch (8)

Lec2 Algorth
Lec2 AlgorthLec2 Algorth
Lec2 Algorth
 
Lecture1
Lecture1Lecture1
Lecture1
 
big_oh
big_ohbig_oh
big_oh
 
CS Fundamentals: Scalability and Memory
CS Fundamentals: Scalability and MemoryCS Fundamentals: Scalability and Memory
CS Fundamentals: Scalability and Memory
 
how to calclute time complexity of algortihm
how to calclute time complexity of algortihmhow to calclute time complexity of algortihm
how to calclute time complexity of algortihm
 
Asymptotic Notation and Data Structures
Asymptotic Notation and Data StructuresAsymptotic Notation and Data Structures
Asymptotic Notation and Data Structures
 
Complexity of Algorithm
Complexity of AlgorithmComplexity of Algorithm
Complexity of Algorithm
 
Time and space complexity
Time and space complexityTime and space complexity
Time and space complexity
 

Ähnlich wie 02 asymp

Asymtotic Appoach.ppt
Asymtotic Appoach.pptAsymtotic Appoach.ppt
Asymtotic Appoach.pptSherylArulini1
 
02-asymp.ppt
02-asymp.ppt02-asymp.ppt
02-asymp.pptAnikGhosh44
 
Lecture3(b).pdf
Lecture3(b).pdfLecture3(b).pdf
Lecture3(b).pdfShaistaRiaz4
 
DAA_LECT_2.pdf
DAA_LECT_2.pdfDAA_LECT_2.pdf
DAA_LECT_2.pdfAryanSaini69
 
Lecture 3(a) Asymptotic-analysis.pdf
Lecture 3(a) Asymptotic-analysis.pdfLecture 3(a) Asymptotic-analysis.pdf
Lecture 3(a) Asymptotic-analysis.pdfShaistaRiaz4
 
Design and analysis of algorithm ppt ppt
Design and analysis of algorithm ppt pptDesign and analysis of algorithm ppt ppt
Design and analysis of algorithm ppt pptsrushtiivp
 
2-AnalysisOfAlgs.ppt
2-AnalysisOfAlgs.ppt2-AnalysisOfAlgs.ppt
2-AnalysisOfAlgs.pptTahseenEjaz3
 
Lecture 4 - Growth of Functions (1).ppt
Lecture 4 - Growth of Functions (1).pptLecture 4 - Growth of Functions (1).ppt
Lecture 4 - Growth of Functions (1).pptZohairMughal1
 
Lecture 4 - Growth of Functions.ppt
Lecture 4 - Growth of Functions.pptLecture 4 - Growth of Functions.ppt
Lecture 4 - Growth of Functions.pptZohairMughal1
 
Skiena algorithm 2007 lecture02 asymptotic notation
Skiena algorithm 2007 lecture02 asymptotic notationSkiena algorithm 2007 lecture02 asymptotic notation
Skiena algorithm 2007 lecture02 asymptotic notationzukun
 
2_Asymptotic notations.pptx
2_Asymptotic notations.pptx2_Asymptotic notations.pptx
2_Asymptotic notations.pptxdattakumar4
 
Unit-1 DAA_Notes.pdf
Unit-1 DAA_Notes.pdfUnit-1 DAA_Notes.pdf
Unit-1 DAA_Notes.pdfAmayJaiswal4
 
Dr hasany 2467_16649_1_lec-2-zabist
Dr hasany 2467_16649_1_lec-2-zabistDr hasany 2467_16649_1_lec-2-zabist
Dr hasany 2467_16649_1_lec-2-zabistGatewayggg Testeru
 
Anlysis and design of algorithms part 1
Anlysis and design of algorithms part 1Anlysis and design of algorithms part 1
Anlysis and design of algorithms part 1Deepak John
 
03 dc
03 dc03 dc
03 dcHira Gul
 
5.2 divide and conquer
5.2 divide and conquer5.2 divide and conquer
5.2 divide and conquerKrish_ver2
 
02 asymptotic notations
02 asymptotic notations02 asymptotic notations
02 asymptotic notationsTarikuDabala1
 

Ähnlich wie 02 asymp (20)

Asymtotic Appoach.ppt
Asymtotic Appoach.pptAsymtotic Appoach.ppt
Asymtotic Appoach.ppt
 
02-asymp.ppt
02-asymp.ppt02-asymp.ppt
02-asymp.ppt
 
Lecture3(b).pdf
Lecture3(b).pdfLecture3(b).pdf
Lecture3(b).pdf
 
DAA_LECT_2.pdf
DAA_LECT_2.pdfDAA_LECT_2.pdf
DAA_LECT_2.pdf
 
Lecture 3(a) Asymptotic-analysis.pdf
Lecture 3(a) Asymptotic-analysis.pdfLecture 3(a) Asymptotic-analysis.pdf
Lecture 3(a) Asymptotic-analysis.pdf
 
Design and analysis of algorithm ppt ppt
Design and analysis of algorithm ppt pptDesign and analysis of algorithm ppt ppt
Design and analysis of algorithm ppt ppt
 
2-AnalysisOfAlgs.ppt
2-AnalysisOfAlgs.ppt2-AnalysisOfAlgs.ppt
2-AnalysisOfAlgs.ppt
 
Lecture 4 - Growth of Functions (1).ppt
Lecture 4 - Growth of Functions (1).pptLecture 4 - Growth of Functions (1).ppt
Lecture 4 - Growth of Functions (1).ppt
 
Lecture 4 - Growth of Functions.ppt
Lecture 4 - Growth of Functions.pptLecture 4 - Growth of Functions.ppt
Lecture 4 - Growth of Functions.ppt
 
Analysis of algorithms
Analysis of algorithmsAnalysis of algorithms
Analysis of algorithms
 
Time complexity
Time complexityTime complexity
Time complexity
 
Skiena algorithm 2007 lecture02 asymptotic notation
Skiena algorithm 2007 lecture02 asymptotic notationSkiena algorithm 2007 lecture02 asymptotic notation
Skiena algorithm 2007 lecture02 asymptotic notation
 
2_Asymptotic notations.pptx
2_Asymptotic notations.pptx2_Asymptotic notations.pptx
2_Asymptotic notations.pptx
 
Asymptotic notations
Asymptotic notationsAsymptotic notations
Asymptotic notations
 
Unit-1 DAA_Notes.pdf
Unit-1 DAA_Notes.pdfUnit-1 DAA_Notes.pdf
Unit-1 DAA_Notes.pdf
 
Dr hasany 2467_16649_1_lec-2-zabist
Dr hasany 2467_16649_1_lec-2-zabistDr hasany 2467_16649_1_lec-2-zabist
Dr hasany 2467_16649_1_lec-2-zabist
 
Anlysis and design of algorithms part 1
Anlysis and design of algorithms part 1Anlysis and design of algorithms part 1
Anlysis and design of algorithms part 1
 
03 dc
03 dc03 dc
03 dc
 
5.2 divide and conquer
5.2 divide and conquer5.2 divide and conquer
5.2 divide and conquer
 
02 asymptotic notations
02 asymptotic notations02 asymptotic notations
02 asymptotic notations
 

KĂŒrzlich hochgeladen

GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTS
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTSGRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTS
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTSJoshuaGantuangco2
 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTiammrhaywood
 
Visit to a blind student's school🧑‍🩯🧑‍🩯(community medicine)
Visit to a blind student's school🧑‍🩯🧑‍🩯(community medicine)Visit to a blind student's school🧑‍🩯🧑‍🩯(community medicine)
Visit to a blind student's school🧑‍🩯🧑‍🩯(community medicine)lakshayb543
 
Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17Celine George
 
Full Stack Web Development Course for Beginners
Full Stack Web Development Course  for BeginnersFull Stack Web Development Course  for Beginners
Full Stack Web Development Course for BeginnersSabitha Banu
 
Roles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceRoles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceSamikshaHamane
 
Science 7 Quarter 4 Module 2: Natural Resources.pptx
Science 7 Quarter 4 Module 2: Natural Resources.pptxScience 7 Quarter 4 Module 2: Natural Resources.pptx
Science 7 Quarter 4 Module 2: Natural Resources.pptxMaryGraceBautista27
 
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptxINTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptxHumphrey A Beña
 
Procuring digital preservation CAN be quick and painless with our new dynamic...
Procuring digital preservation CAN be quick and painless with our new dynamic...Procuring digital preservation CAN be quick and painless with our new dynamic...
Procuring digital preservation CAN be quick and painless with our new dynamic...Jisc
 
Earth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatEarth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatYousafMalik24
 
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdfAMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdfphamnguyenenglishnb
 
Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17Celine George
 
Karra SKD Conference Presentation Revised.pptx
Karra SKD Conference Presentation Revised.pptxKarra SKD Conference Presentation Revised.pptx
Karra SKD Conference Presentation Revised.pptxAshokKarra1
 
Barangay Council for the Protection of Children (BCPC) Orientation.pptx
Barangay Council for the Protection of Children (BCPC) Orientation.pptxBarangay Council for the Protection of Children (BCPC) Orientation.pptx
Barangay Council for the Protection of Children (BCPC) Orientation.pptxCarlos105
 
Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Celine George
 
USPSÂź Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
USPSÂź Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...USPSÂź Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
USPSÂź Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...Postal Advocate Inc.
 

KĂŒrzlich hochgeladen (20)

GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTS
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTSGRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTS
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTS
 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
 
Raw materials used in Herbal Cosmetics.pptx
Raw materials used in Herbal Cosmetics.pptxRaw materials used in Herbal Cosmetics.pptx
Raw materials used in Herbal Cosmetics.pptx
 
Visit to a blind student's school🧑‍🩯🧑‍🩯(community medicine)
Visit to a blind student's school🧑‍🩯🧑‍🩯(community medicine)Visit to a blind student's school🧑‍🩯🧑‍🩯(community medicine)
Visit to a blind student's school🧑‍🩯🧑‍🩯(community medicine)
 
FINALS_OF_LEFT_ON_C'N_EL_DORADO_2024.pptx
FINALS_OF_LEFT_ON_C'N_EL_DORADO_2024.pptxFINALS_OF_LEFT_ON_C'N_EL_DORADO_2024.pptx
FINALS_OF_LEFT_ON_C'N_EL_DORADO_2024.pptx
 
Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17
 
Full Stack Web Development Course for Beginners
Full Stack Web Development Course  for BeginnersFull Stack Web Development Course  for Beginners
Full Stack Web Development Course for Beginners
 
OS-operating systems- ch04 (Threads) ...
OS-operating systems- ch04 (Threads) ...OS-operating systems- ch04 (Threads) ...
OS-operating systems- ch04 (Threads) ...
 
Roles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceRoles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in Pharmacovigilance
 
Science 7 Quarter 4 Module 2: Natural Resources.pptx
Science 7 Quarter 4 Module 2: Natural Resources.pptxScience 7 Quarter 4 Module 2: Natural Resources.pptx
Science 7 Quarter 4 Module 2: Natural Resources.pptx
 
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptxINTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
 
Procuring digital preservation CAN be quick and painless with our new dynamic...
Procuring digital preservation CAN be quick and painless with our new dynamic...Procuring digital preservation CAN be quick and painless with our new dynamic...
Procuring digital preservation CAN be quick and painless with our new dynamic...
 
Earth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatEarth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice great
 
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdfAMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
 
Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17
 
Karra SKD Conference Presentation Revised.pptx
Karra SKD Conference Presentation Revised.pptxKarra SKD Conference Presentation Revised.pptx
Karra SKD Conference Presentation Revised.pptx
 
Barangay Council for the Protection of Children (BCPC) Orientation.pptx
Barangay Council for the Protection of Children (BCPC) Orientation.pptxBarangay Council for the Protection of Children (BCPC) Orientation.pptx
Barangay Council for the Protection of Children (BCPC) Orientation.pptx
 
YOUVE_GOT_EMAIL_PRELIMS_EL_DORADO_2024.pptx
YOUVE_GOT_EMAIL_PRELIMS_EL_DORADO_2024.pptxYOUVE_GOT_EMAIL_PRELIMS_EL_DORADO_2024.pptx
YOUVE_GOT_EMAIL_PRELIMS_EL_DORADO_2024.pptx
 
Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17
 
USPSÂź Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
USPSÂź Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...USPSÂź Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
USPSÂź Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
 

02 asymp

  • 1. Asymptotic Notation, Asymptotic Notation, Review of Functions & Review of Functions & Summations Summations December 20, 2013 Comp 122, Spring 2004
  • 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. ymp - 2 Comp 122
  • 3. 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
  • 4. Θ-notation For function g(n), we define Θ(g(n)), big-Theta of n, as the set: Θ(g(n)) = {f(n) : ∃ positive constants c1, c2, and n0, such that ∀n ≄ n0, we have 0 ≀ c1g(n) ≀ f(n) ≀ c2g(n) } Intuitively: Set of all functions that have the same rate of growth as g(n). g(n) is an asymptotically tight bound for f(n). ymp - 4 Comp 122
  • 5. Θ-notation For function g(n), we define Θ(g(n)), big-Theta of n, as the set: Θ(g(n)) = {f(n) : ∃ positive constants c1, c2, and n0, such that ∀n ≄ n0, we have 0 ≀ c1g(n) ≀ f(n) ≀ c2g(n) } 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. ymp - 5 Comp 122
  • 6. ymp - 6 Example Θ(g(n)) = {f(n) : ∃ positive constants c1, c2, and n0, such that ∀n ≄ n0, 0 ≀ c1g(n) ≀ f(n) ≀ c2g(n)}  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) Comp 122
  • 7. ymp - 7 Example Θ(g(n)) = {f(n) : ∃ positive constants c1, c2, and n0, such that ∀n ≄ n0, 0 ≀ c1g(n) ≀ f(n) ≀ c2g(n)}  Is 3n3 ∈ Θ(n4) ??  How about 22n∈ Θ(2n)?? Comp 122
  • 8. O-notation For function g(n), we define O(g(n)), big-O of n, as the set: O(g(n)) = {f(n) : ∃ positive constants c and n0, such that ∀n ≄ n0, we have 0 ≀ f(n) ≀ cg(n) } Intuitively: Set of all functions whose rate of growth is the same as or lower than that of g(n). g(n) is an asymptotic upper bound for f(n). f(n) = Θ(g(n)) ⇒ f(n) = O(g(n)). Θ(g(n)) ⊂ O(g(n)). ymp - 8 Comp 122
  • 9. Examples O(g(n)) = {f(n) : ∃ positive constants c and n0, such that ∀n ≄ n0, we have 0 ≀ f(n) ≀ cg(n) }  Any linear function an + b is in O(n2). How?  Show that 3n3=O(n4) for appropriate c and n0. ymp - 9 Comp 122
  • 10. ℩ -notation For function g(n), we define ℩(g(n)), big-Omega of n, as the set: ℩(g(n)) = {f(n) : ∃ positive constants c and n0, such that ∀n ≄ n0, we have 0 ≀ cg(n) ≀ f(n)} Intuitively: Set of all functions whose rate of growth is the same as or higher than that of g(n). g(n) is an asymptotic lower bound for f(n). ymp - 10 f(n) = Θ(g(n)) ⇒ f(n) = ℩(g(n)). Θ(g(n)) ⊂ ℩(g(n)). Comp 122
  • 11. Example ℩(g(n)) = {f(n) : ∃ positive constants c and n0, such that ∀n ≄ n0, we have 0 ≀ cg(n) ≀ f(n)}  √n = ℩(lg n). Choose c and n0. ymp - 11 Comp 122
  • 12. ymp - 12 Relations Between Θ, O, ℩ Comp 122
  • 13. Relations Between Θ, ℩, O Theorem :: For any two functions g(n) and f(n), Theorem For any two functions g(n) and f(n), f(n) = Θ(g(n)) iff f(n) = Θ(g(n)) iff f(n) = O(g(n)) and f(n) = ℩(g(n)). f(n) = O(g(n)) and f(n) = ℩(g(n)).  I.e., Θ(g(n)) = O(g(n)) ∩ ℩(g(n))  In practice, asymptotically tight bounds are obtained from asymptotic upper and lower bounds. ymp - 13 Comp 122
  • 14. 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
  • 15. 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
  • 16. 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
  • 17. o-notation For a given function g(n), the set little-o: o(g(n)) = {f(n): ∀ c > 0, ∃ n0 > 0 such that ∀ n ≄ n0, we have 0 ≀ f(n) < cg(n)}. 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? ymp - 17 Comp 122
  • 18. ω -notation For a given function g(n), the set little-omega: ω(g(n)) = {f(n): ∀ c > 0, ∃ n > 0 such that ∀ n ≄ n0, we have 0 ≀ cg(n) < f(n)}. 0 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. ymp - 18 Comp 122
  • 19. 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
  • 20. 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
  • 21. 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
  • 22. 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)) Comp 122
  • 23. Common Functions December 20, 2013 Comp 122, Spring 2004
  • 24. Monotonicity  f(n) is ymp - 24 ïł ïł ïł ïł 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
  • 25. Exponentials  Useful Identities: 1 a = a (a m ) n = a mn −1 a m a n = a m+ n  Exponentials and polynomials ymp - 25 nb lim n = 0 n→∞ a ⇒ n b = o( a n ) Comp 122
  • 26. Logarithms x = logba is the exponent for a = bx. a = b logb a log c (ab) = log c a + log c b log b a = n log b a n Natural log: ln a = logea Binary log: lg a = log2a lg2a = (lg a)2 lg lg a = lg (lg a) ymp - 26 log c a log b a = log c b log b (1 / a ) = − log b a 1 log b a = log a b a logb c = c logb a Comp 122
  • 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). ymp - 27 ïł Ex: 2n = (2/3)n*3n. Comp 122
  • 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) ymp - 28 ïł Prove using Stirling’s approximation (in the text) for lg(n!). Comp 122
  • 29. Exercise Express functions in A in asymptotic notation using functions in B. ymp - 29 A 5n2 + 100n B 3n2 + 2 A ∈ Θ(B) A ∈ Θ(n2), n2 ∈ Θ(B) ⇒ A ∈ Θ(B) log3(n2) log2(n3) A ∈ Θ(B) logba = logca / logcb; A = 2lgn / lg3, B = 3lgn, A/B =2/(3lg3) A ∈ ω (B) nlg4 3lg n alog b = blog a; B =3lg n=nlg 3; A/B =nlg(4/3) → ∞ as n→∞ A ∈ Îż (B) lg2n n1/2 lim ( lga n / nb ) = 0 (here a = 2 and b = 1/2) ⇒ A ∈ Îż (B) n→∞ Comp 122
  • 30. Summations – Review December 20, 2013 Comp 122, Spring 2004
  • 31. 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 Comp 122 2
  • 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? ymp - 32 Comp 122
  • 33. Review on Summations  Constant Series: For integers a and b, a ≀ b, b ∑1 = b − a + 1 i =a  Linear Series (Arithmetic Series): For n ≄ 0, n n(n + 1) ∑ i = 1 + 2 + + n = 2 i =1 n  Quadratic Series: For n 2≄ 0, 2 n(n + 1)(2n + 1) i 2 = 12 + 2 +  + n = ymp - 33 ∑ 6 i =1 Comp 122
  • 34. ymp - 34 Review on Summations  Cubic Series: For n ≄ 0, n 2 (n + 1) 2 i 3 = 13 + 23 +  + n 3 = ∑ 4 i =1 n  Geometric Series: For real x ≠ 1, x n+1 − 1 xk = 1+ x + x2 +  + xn = ∑ x −1 k =0 n For |x| < 1, ∞ 1 ∑ x = 1− x k =0 k Comp 122
  • 35. ymp - 35 Review on Summations  Linear-Geometric Series: For n ≄ 0, real c ≠ 1, n +1 − (n + 1)c + nc ∑ ic = c + 2c +  + nc = (c − 1) 2 i =1 n i 2 n  Harmonic Series: nth harmonic number, n∈I+, 1 1 1 Hn = 1+ + ++ 2 3 n n 1 = ∑ = ln(n) + O(1) k =1 k Comp 122 n+ 2 +c
  • 36. Review on Summations  Telescoping Series: n ∑a k =1 k − ak −1 = an − a0  Differentiating Series: For |x| < 1, ymp - 36 ∞ x ∑ kx = (1 − x ) 2 k =0 k Comp 122
  • 37. Review on Summations  Approximation by integrals: ïł For monotonically increasing f(n) n ∫ m−1 n n +1 k =m m f ( x)dx ≀ ∑ f (k ) ≀ ∫ f ( x)dx ïł For monotonically decreasing f(n) n +1 ∫ m n f ( x)dx ≀ ∑ f (k ) ≀ k =m n ∫ f ( x)dx m−1  How? ymp - 37 Comp 122
  • 38. Review on Summations  nth harmonic number ymp - 38 n 1 ∑k ≄ k =1 n+1 ∫ 1 dx = ln(n + 1) x n n 1 dx ≀ ∫ = ln n ∑k x k =2 1 n 1 ⇒ ∑ ≀ ln n + 1 k =1 k Comp 122
  • 39. Reading Assignment  Chapter 4 of CLRS. ymp - 39 Comp 122