Summations COSC 3101, PROF. J. ELDER 2 Recall: Insertion Sort.
-
Upload
barbra-malone -
Category
Documents
-
view
226 -
download
2
Transcript of Summations COSC 3101, PROF. J. ELDER 2 Recall: Insertion Sort.
![Page 1: Summations COSC 3101, PROF. J. ELDER 2 Recall: Insertion Sort.](https://reader030.fdocuments.net/reader030/viewer/2022020102/5697bfaf1a28abf838c9cfa0/html5/thumbnails/1.jpg)
Summationsn
i=1
Evaluating f (i)
![Page 2: Summations COSC 3101, PROF. J. ELDER 2 Recall: Insertion Sort.](https://reader030.fdocuments.net/reader030/viewer/2022020102/5697bfaf1a28abf838c9cfa0/html5/thumbnails/2.jpg)
COSC 3101, PROF. J. ELDER 2
Recall: Insertion Sort
2
2
( 1)Worst case (reverse order): : 1 ( ) ( )
2
n
jj
n nt j j T n n
![Page 3: Summations COSC 3101, PROF. J. ELDER 2 Recall: Insertion Sort.](https://reader030.fdocuments.net/reader030/viewer/2022020102/5697bfaf1a28abf838c9cfa0/html5/thumbnails/3.jpg)
COSC 3101, PROF. J. ELDER 3
∑i=1..n i = 1 + 2 + 3 + . . . + n
= ?
Arithmetic Sum
![Page 4: Summations COSC 3101, PROF. J. ELDER 2 Recall: Insertion Sort.](https://reader030.fdocuments.net/reader030/viewer/2022020102/5697bfaf1a28abf838c9cfa0/html5/thumbnails/4.jpg)
COSC 3101, PROF. J. ELDER 4
1 + 2 + 3 + . . . + n-1 + n = S
n + n-1 + n-2 + . . . + 2 + 1 = S
(n+1) + (n+1) + (n+1) + . . . + (n+1) + (n+1) = 2S
n (n+1) = 2S
2
1)(n n S
![Page 5: Summations COSC 3101, PROF. J. ELDER 2 Recall: Insertion Sort.](https://reader030.fdocuments.net/reader030/viewer/2022020102/5697bfaf1a28abf838c9cfa0/html5/thumbnails/5.jpg)
COSC 3101, PROF. J. ELDER 5
Let’s restate this argument using a
geometric representation
Algebraic argument
1 + 2 + 3 + . . . + n-1 + n = S
n + n-1 + n-2 + . . . + 2 + 1 = S
(n+1) + (n+1) + (n+1) + . . . + (n+1) + (n+1) = 2S
n (n+1) = 2S
![Page 6: Summations COSC 3101, PROF. J. ELDER 2 Recall: Insertion Sort.](https://reader030.fdocuments.net/reader030/viewer/2022020102/5697bfaf1a28abf838c9cfa0/html5/thumbnails/6.jpg)
COSC 3101, PROF. J. ELDER 6
1 2 . . . . . . . . n
= number of blue dots.
1 + 2 + 3 + . . . + n-1 + n = S
n + n-1 + n-2 + . . . + 2 + 1 = S
(n+1) + (n+1) + (n+1) + . . . + (n+1) + (n+1) = 2S
n (n+1) = 2S
![Page 7: Summations COSC 3101, PROF. J. ELDER 2 Recall: Insertion Sort.](https://reader030.fdocuments.net/reader030/viewer/2022020102/5697bfaf1a28abf838c9cfa0/html5/thumbnails/7.jpg)
COSC 3101, PROF. J. ELDER 7
1 2 . . . . . . . . n
= number of blue dots
= number of black dots
n . . . . . . . 2 1
1 + 2 + 3 + . . . + n-1 + n = S
n + n-1 + n-2 + . . . + 2 + 1 = S
(n+1) + (n+1) + (n+1) + . . . + (n+1) + (n+1) = 2S
n (n+1) = 2S
![Page 8: Summations COSC 3101, PROF. J. ELDER 2 Recall: Insertion Sort.](https://reader030.fdocuments.net/reader030/viewer/2022020102/5697bfaf1a28abf838c9cfa0/html5/thumbnails/8.jpg)
COSC 3101, PROF. J. ELDER 8
n+1 n+1 n+1 n+1 n+1
n
n
n
n
n
n
There are n(n+1) dots in the grid
(n+1) + (n+1) + (n+1) + . . . + (n+1) + (n+1) = 2S
n (n+1) = 2S
= number of blue dots
= number of black dots
1 + 2 + 3 + . . . + n-1 + n = S
n + n-1 + n-2 + . . . + 2 + 1 = S
![Page 9: Summations COSC 3101, PROF. J. ELDER 2 Recall: Insertion Sort.](https://reader030.fdocuments.net/reader030/viewer/2022020102/5697bfaf1a28abf838c9cfa0/html5/thumbnails/9.jpg)
COSC 3101, PROF. J. ELDER 9
n+1 n+1 n+1 n+1 n+1
n
n
n
n
n
n
Note = (# of terms · last term))
(n+1) + (n+1) + (n+1) + . . . + (n+1) + (n+1) = 2S
n (n+1) = 2S
= number of blue dots
= number of black dots
1 + 2 + 3 + . . . + n-1 + n = S
n + n-1 + n-2 + . . . + 2 + 1 = S
2
1)(n n S
![Page 10: Summations COSC 3101, PROF. J. ELDER 2 Recall: Insertion Sort.](https://reader030.fdocuments.net/reader030/viewer/2022020102/5697bfaf1a28abf838c9cfa0/html5/thumbnails/10.jpg)
COSC 3101, PROF. J. ELDER 10
∑i=1..n i = 1 + 2 + 3 + . . . + n
= (# of terms · last term)
Arithmetic Sum
True whenever terms increase slowly
![Page 11: Summations COSC 3101, PROF. J. ELDER 2 Recall: Insertion Sort.](https://reader030.fdocuments.net/reader030/viewer/2022020102/5697bfaf1a28abf838c9cfa0/html5/thumbnails/11.jpg)
COSC 3101, PROF. J. ELDER 11
∑i=0..n 2i = 1 + 2 + 4 + 8 +. . . + 2n
= ?
Geometric Sum
![Page 12: Summations COSC 3101, PROF. J. ELDER 2 Recall: Insertion Sort.](https://reader030.fdocuments.net/reader030/viewer/2022020102/5697bfaf1a28abf838c9cfa0/html5/thumbnails/12.jpg)
COSC 3101, PROF. J. ELDER 12
Geometric Sum
![Page 13: Summations COSC 3101, PROF. J. ELDER 2 Recall: Insertion Sort.](https://reader030.fdocuments.net/reader030/viewer/2022020102/5697bfaf1a28abf838c9cfa0/html5/thumbnails/13.jpg)
COSC 3101, PROF. J. ELDER 13
∑i=0..n 2i = 1 + 2 + 4 + 8 +. . . + 2n
= 2 · last term - 1
Geometric Sum
![Page 14: Summations COSC 3101, PROF. J. ELDER 2 Recall: Insertion Sort.](https://reader030.fdocuments.net/reader030/viewer/2022020102/5697bfaf1a28abf838c9cfa0/html5/thumbnails/14.jpg)
COSC 3101, PROF. J. ELDER 14
∑i=0..n ri = r0 + r1 + r2 +. . . + rn
= ?
Geometric Sum
![Page 15: Summations COSC 3101, PROF. J. ELDER 2 Recall: Insertion Sort.](https://reader030.fdocuments.net/reader030/viewer/2022020102/5697bfaf1a28abf838c9cfa0/html5/thumbnails/15.jpg)
COSC 3101, PROF. J. ELDER 15
S
Sr r r r ... r r
S Sr 1 r
Sr 1
r 1
2 3 n n 1
n 1
n 1
1 r r r ...2 3 rn
Geometric Sum
![Page 16: Summations COSC 3101, PROF. J. ELDER 2 Recall: Insertion Sort.](https://reader030.fdocuments.net/reader030/viewer/2022020102/5697bfaf1a28abf838c9cfa0/html5/thumbnails/16.jpg)
COSC 3101, PROF. J. ELDER 16
∑i=0..n rir 1
r 1
n 1
Geometric Sum
θ(rn)Biggest TermWhen r>1
![Page 17: Summations COSC 3101, PROF. J. ELDER 2 Recall: Insertion Sort.](https://reader030.fdocuments.net/reader030/viewer/2022020102/5697bfaf1a28abf838c9cfa0/html5/thumbnails/17.jpg)
COSC 3101, PROF. J. ELDER 17
∑i=0..n ri = r0 + r1 + r2 +. . . + rn
= (biggest term)
Geometric Increasing
True whenever terms increase quickly
![Page 18: Summations COSC 3101, PROF. J. ELDER 2 Recall: Insertion Sort.](https://reader030.fdocuments.net/reader030/viewer/2022020102/5697bfaf1a28abf838c9cfa0/html5/thumbnails/18.jpg)
COSC 3101, PROF. J. ELDER 18
∑i=0..n ri
Geometric Sum
When r<1?1 r
1 r
n 1
![Page 19: Summations COSC 3101, PROF. J. ELDER 2 Recall: Insertion Sort.](https://reader030.fdocuments.net/reader030/viewer/2022020102/5697bfaf1a28abf838c9cfa0/html5/thumbnails/19.jpg)
COSC 3101, PROF. J. ELDER 19
∑i=0..n ri
Geometric Sum
1 r
1 r
n 1
θ(1)When r<1
Biggest Term
![Page 20: Summations COSC 3101, PROF. J. ELDER 2 Recall: Insertion Sort.](https://reader030.fdocuments.net/reader030/viewer/2022020102/5697bfaf1a28abf838c9cfa0/html5/thumbnails/20.jpg)
COSC 3101, PROF. J. ELDER 20
∑i=0..n ri = r0 + r1 + r2 +. . . + rn
= (1)
Bounded Tail
True whenever terms decrease quickly
![Page 21: Summations COSC 3101, PROF. J. ELDER 2 Recall: Insertion Sort.](https://reader030.fdocuments.net/reader030/viewer/2022020102/5697bfaf1a28abf838c9cfa0/html5/thumbnails/21.jpg)
COSC 3101, PROF. J. ELDER 21
f(i) = 1∑i=1..n f(i) = n
n
Sum of Shrinking Function
![Page 22: Summations COSC 3101, PROF. J. ELDER 2 Recall: Insertion Sort.](https://reader030.fdocuments.net/reader030/viewer/2022020102/5697bfaf1a28abf838c9cfa0/html5/thumbnails/22.jpg)
COSC 3101, PROF. J. ELDER 22
f(i) = 1/2i
Sum of Shrinking Function
1
1 11 (1)
2 2
n
i ni
![Page 23: Summations COSC 3101, PROF. J. ELDER 2 Recall: Insertion Sort.](https://reader030.fdocuments.net/reader030/viewer/2022020102/5697bfaf1a28abf838c9cfa0/html5/thumbnails/23.jpg)
COSC 3101, PROF. J. ELDER 23
f(i) = 1/i∑i=1..n f(i) = ?
n
Sum of Shrinking Function
![Page 24: Summations COSC 3101, PROF. J. ELDER 2 Recall: Insertion Sort.](https://reader030.fdocuments.net/reader030/viewer/2022020102/5697bfaf1a28abf838c9cfa0/html5/thumbnails/24.jpg)
COSC 3101, PROF. J. ELDER 24
∑i=1..n 1/i
= 1/1 + 1/2 + 1/3 + 1/4 + 1/5 + …+ 1/n
= ?
Harmonic Sum
![Page 25: Summations COSC 3101, PROF. J. ELDER 2 Recall: Insertion Sort.](https://reader030.fdocuments.net/reader030/viewer/2022020102/5697bfaf1a28abf838c9cfa0/html5/thumbnails/25.jpg)
Harmonic Sum
2 2 21 1
From this it f ollows that
1 1 1log log ( 1) 1 (log )
2
n n
i i
n n ni i
![Page 26: Summations COSC 3101, PROF. J. ELDER 2 Recall: Insertion Sort.](https://reader030.fdocuments.net/reader030/viewer/2022020102/5697bfaf1a28abf838c9cfa0/html5/thumbnails/26.jpg)
COSC 3101, PROF. J. ELDER 26
∑i=1..n 1/i
= 1/1 + 1/2 + 1/3 + 1/4 + 1/5 + …+ 1/n
= (log(n))
Harmonic Sum
![Page 27: Summations COSC 3101, PROF. J. ELDER 2 Recall: Insertion Sort.](https://reader030.fdocuments.net/reader030/viewer/2022020102/5697bfaf1a28abf838c9cfa0/html5/thumbnails/27.jpg)
COSC 3101, PROF. J. ELDER 27
Approximating Sum by Integrating
The area under the curve approximates the sum
∑i=1..n f(i) ≈ ∫x=1..n f(x) dx
![Page 28: Summations COSC 3101, PROF. J. ELDER 2 Recall: Insertion Sort.](https://reader030.fdocuments.net/reader030/viewer/2022020102/5697bfaf1a28abf838c9cfa0/html5/thumbnails/28.jpg)
COSC 3101, PROF. J. ELDER 28
Approximating Sums by Integrating: Harmonic Sum
11 1
1 1log log
nnn
i
dx x ni x
![Page 29: Summations COSC 3101, PROF. J. ELDER 2 Recall: Insertion Sort.](https://reader030.fdocuments.net/reader030/viewer/2022020102/5697bfaf1a28abf838c9cfa0/html5/thumbnails/29.jpg)
COSC 3101, PROF. J. ELDER 29
1 1
0 0
1( ) ( )
1
(number of terms last term)
(True whenever terms increase slowly)
nnc c c c c
i
i x dx n n n nc
Approximating Sums by Integrating: Arithmetic Sums
![Page 30: Summations COSC 3101, PROF. J. ELDER 2 Recall: Insertion Sort.](https://reader030.fdocuments.net/reader030/viewer/2022020102/5697bfaf1a28abf838c9cfa0/html5/thumbnails/30.jpg)
COSC 3101, PROF. J. ELDER 30
0 00
1 1( 1) ( )
ln ln
(last term)
(True whenever terms increase rapidly)
nnni x x n n
i
b b dx b b bb b
Approximating Sums by Integrating: Geometric Sum
![Page 31: Summations COSC 3101, PROF. J. ELDER 2 Recall: Insertion Sort.](https://reader030.fdocuments.net/reader030/viewer/2022020102/5697bfaf1a28abf838c9cfa0/html5/thumbnails/31.jpg)
COSC 3101, PROF. J. ELDER 31
Adding Made Easy
We will now classify (most) functions f(i) into four classes:
–Geometric Like–Arithmetic Like–Harmonic–Bounded Tail
For each class, we will give an easy rule for approximating its sum θ( ∑i=1..n f(i) )
![Page 32: Summations COSC 3101, PROF. J. ELDER 2 Recall: Insertion Sort.](https://reader030.fdocuments.net/reader030/viewer/2022020102/5697bfaf1a28abf838c9cfa0/html5/thumbnails/32.jpg)
COSC 3101, PROF. J. ELDER 32
Adding Made Easy
f(n)
n
Harmonic
( ) (log )f n n
![Page 33: Summations COSC 3101, PROF. J. ELDER 2 Recall: Insertion Sort.](https://reader030.fdocuments.net/reader030/viewer/2022020102/5697bfaf1a28abf838c9cfa0/html5/thumbnails/33.jpg)
COSC 3101, PROF. J. ELDER 33
If the terms f(i) grow sufficiently quickly, then the sum will
be dominated by the largest term.
f(n) 2Ω(n) ∑i=0..n f(i) = θ(f(n))
Geometric Like:
Classic example:
∑i=0..n 2i = 2n+1-1 ≈ 2 f(n)
![Page 34: Summations COSC 3101, PROF. J. ELDER 2 Recall: Insertion Sort.](https://reader030.fdocuments.net/reader030/viewer/2022020102/5697bfaf1a28abf838c9cfa0/html5/thumbnails/34.jpg)
COSC 3101, PROF. J. ELDER 34
If the terms f(i) grow sufficiently quickly, then the sum will
be dominated by the largest term.
f(n) 2Ω(n) ∑i=1..n f(i) = θ(f(n))
Geometric Like:
For which functions f(i) is this true?
How fast and how slow can it grow?
![Page 35: Summations COSC 3101, PROF. J. ELDER 2 Recall: Insertion Sort.](https://reader030.fdocuments.net/reader030/viewer/2022020102/5697bfaf1a28abf838c9cfa0/html5/thumbnails/35.jpg)
COSC 3101, PROF. J. ELDER 35
∑i=1..n (1000)i ≈ 1.001(1000)n
= 1.001 f(n)
Even bigger?
f(n) 2Ω(n) ∑i=1..n f(i) = θ(f(n))
Geometric Like:
![Page 36: Summations COSC 3101, PROF. J. ELDER 2 Recall: Insertion Sort.](https://reader030.fdocuments.net/reader030/viewer/2022020102/5697bfaf1a28abf838c9cfa0/html5/thumbnails/36.jpg)
COSC 3101, PROF. J. ELDER 36
2n2i
∑i=1..n 22 ≈ 22 = 1f(n)
No Upper Extreme:
Even bigger!
f(n) 2Ω(n) ∑i=1..n f(i) = θ(f(n))
Geometric Like:
![Page 37: Summations COSC 3101, PROF. J. ELDER 2 Recall: Insertion Sort.](https://reader030.fdocuments.net/reader030/viewer/2022020102/5697bfaf1a28abf838c9cfa0/html5/thumbnails/37.jpg)
COSC 3101, PROF. J. ELDER 37
f(n) 2Ω(n) ∑i=1..n f(i) = θ(f(n))
Geometric Like:
3 ( )100 100
2 2e.g. ( ) 8 ( ( )) ( ) 2
(The strongest f unction determines the class.)
n nnf n n f n
n n
![Page 38: Summations COSC 3101, PROF. J. ELDER 2 Recall: Insertion Sort.](https://reader030.fdocuments.net/reader030/viewer/2022020102/5697bfaf1a28abf838c9cfa0/html5/thumbnails/38.jpg)
COSC 3101, PROF. J. ELDER 38
f(n) 2Ω(n) ∑i=1..n f(i) = θ(f(n))
Geometric Like:
32 41
1
2
3 4
( )
1
In general, if ( ) log
where
1
,
Then ( ) 2
and ( ) ( ( ))
cc n c
n
n
i
f n c b n n
b
c
c
c c
f n
f i f n
![Page 39: Summations COSC 3101, PROF. J. ELDER 2 Recall: Insertion Sort.](https://reader030.fdocuments.net/reader030/viewer/2022020102/5697bfaf1a28abf838c9cfa0/html5/thumbnails/39.jpg)
COSC 3101, PROF. J. ELDER 39
Do All functions in 2Ω(n) have this property?Maybe not.
f(n) 2Ω(n) ∑i=1..n f(i) = θ(f(n))Geometric Like:
![Page 40: Summations COSC 3101, PROF. J. ELDER 2 Recall: Insertion Sort.](https://reader030.fdocuments.net/reader030/viewer/2022020102/5697bfaf1a28abf838c9cfa0/html5/thumbnails/40.jpg)
COSC 3101, PROF. J. ELDER 40
Functions that oscillate with exponentially increasing amplitude do not have this property.
f(n) 2Ω(n) ∑i=1..n f(i) = θ(f(n))Geometric Like:
![Page 41: Summations COSC 3101, PROF. J. ELDER 2 Recall: Insertion Sort.](https://reader030.fdocuments.net/reader030/viewer/2022020102/5697bfaf1a28abf838c9cfa0/html5/thumbnails/41.jpg)
COSC 3101, PROF. J. ELDER 41
Functions expressed with +, -, , , exp, log
do not oscillate continually.
They are well behaved for sufficiently large n.
These do have this property.
f(n) 2Ω(n) ∑i=1..n f(i) = θ(f(n))Geometric Like:
![Page 42: Summations COSC 3101, PROF. J. ELDER 2 Recall: Insertion Sort.](https://reader030.fdocuments.net/reader030/viewer/2022020102/5697bfaf1a28abf838c9cfa0/html5/thumbnails/42.jpg)
COSC 3101, PROF. J. ELDER 42
Adding Made Easy
f(n)
n
![Page 43: Summations COSC 3101, PROF. J. ELDER 2 Recall: Insertion Sort.](https://reader030.fdocuments.net/reader030/viewer/2022020102/5697bfaf1a28abf838c9cfa0/html5/thumbnails/43.jpg)
COSC 3101, PROF. J. ELDER 43
If the terms f(i) are increasing or decreasing relatively slowly, then the sum is roughly the number of terms, n, times the final value.
Example 1:
∑i=1..n 1 = n · 1
f(n) = nθ(1)-1 ∑i=1..n f(i) = θ(n·f(n))Arithmetic Like:
![Page 44: Summations COSC 3101, PROF. J. ELDER 2 Recall: Insertion Sort.](https://reader030.fdocuments.net/reader030/viewer/2022020102/5697bfaf1a28abf838c9cfa0/html5/thumbnails/44.jpg)
COSC 3101, PROF. J. ELDER 44
If the terms f(i) are increasing or decreasing relatively slowly, then the sum is roughly the number of terms, n, times the final value.
Example 2:
∑i=1..n i = 1 + 2 + 3 + . . . + n
f(n) = nθ(1)-1 ∑i=1..n f(i) = θ(n·f(n))Arithmetic Like:
1
( 1)2n n
![Page 45: Summations COSC 3101, PROF. J. ELDER 2 Recall: Insertion Sort.](https://reader030.fdocuments.net/reader030/viewer/2022020102/5697bfaf1a28abf838c9cfa0/html5/thumbnails/45.jpg)
COSC 3101, PROF. J. ELDER 45
Note that the final term is within a constant multiple of the middle term:
Thus half the terms are roughly the same and the sum is roughly the number of terms, n, times this value
∑i=1..n i =
1 + . . . + n/2 + . . . + n
∑i=1..n i = θ(n · n)
f(n) = nθ(1)-1 ∑i=1..n f(i) = θ(n·f(n))Arithmetic Like:
( )
2( / 2) / 2
f n n
f n n
![Page 46: Summations COSC 3101, PROF. J. ELDER 2 Recall: Insertion Sort.](https://reader030.fdocuments.net/reader030/viewer/2022020102/5697bfaf1a28abf838c9cfa0/html5/thumbnails/46.jpg)
COSC 3101, PROF. J. ELDER 46
Is the statement true for this function?
∑i=1..n i2 = 12 + 22 + 32 + . . . + n2
f(n) = nθ(1)-1 ∑i=1..n f(i) = θ(n·f(n))Arithmetic Like:
![Page 47: Summations COSC 3101, PROF. J. ELDER 2 Recall: Insertion Sort.](https://reader030.fdocuments.net/reader030/viewer/2022020102/5697bfaf1a28abf838c9cfa0/html5/thumbnails/47.jpg)
COSC 3101, PROF. J. ELDER 47
Again half the terms are roughly the same.
∑i=1..n i =
12 + . . . + (n/2)2 + . . . + n2
1/4 n2
f(n) = nθ(1)-1 ∑i=1..n f(i) = θ(n·f(n))Arithmetic Like:
∑i=1..n i2 = θ(n · n2)
![Page 48: Summations COSC 3101, PROF. J. ELDER 2 Recall: Insertion Sort.](https://reader030.fdocuments.net/reader030/viewer/2022020102/5697bfaf1a28abf838c9cfa0/html5/thumbnails/48.jpg)
COSC 3101, PROF. J. ELDER 48
area of small square
∑i=1..n f(i)
≈ area under curve
area of big square
f(n) = nθ(1)-1 ∑i=1..n f(i) = θ(n·f(n))Arithmetic Like:
= n/2 · f(n/2)
n · f(n)
![Page 49: Summations COSC 3101, PROF. J. ELDER 2 Recall: Insertion Sort.](https://reader030.fdocuments.net/reader030/viewer/2022020102/5697bfaf1a28abf838c9cfa0/html5/thumbnails/49.jpg)
COSC 3101, PROF. J. ELDER 49
∑i=1..n i2 = 12 + 22 + 32 + . . . + n2
f(n) = nθ(1)-1 ∑i=1..n f(i) = θ(n·f(n))Arithmetic Like:
f(n) = n2
f(n/2) = θ(f(n))
The key property is
= ?
![Page 50: Summations COSC 3101, PROF. J. ELDER 2 Recall: Insertion Sort.](https://reader030.fdocuments.net/reader030/viewer/2022020102/5697bfaf1a28abf838c9cfa0/html5/thumbnails/50.jpg)
COSC 3101, PROF. J. ELDER 50
Adding Made Easy
Half done
f(n)
n
![Page 51: Summations COSC 3101, PROF. J. ELDER 2 Recall: Insertion Sort.](https://reader030.fdocuments.net/reader030/viewer/2022020102/5697bfaf1a28abf838c9cfa0/html5/thumbnails/51.jpg)
COSC 3101, PROF. J. ELDER 51
f(i) = 1∑i=1..n f(i) = θ(n)
n
Sum of Shrinking Function
![Page 52: Summations COSC 3101, PROF. J. ELDER 2 Recall: Insertion Sort.](https://reader030.fdocuments.net/reader030/viewer/2022020102/5697bfaf1a28abf838c9cfa0/html5/thumbnails/52.jpg)
COSC 3101, PROF. J. ELDER 52
f(i) = ?∑i=1..n f(i) = θ(n1/2)
n
Sum of Shrinking Function
1/i1/2 (1) 1( )
1(1)
2
f n n
![Page 53: Summations COSC 3101, PROF. J. ELDER 2 Recall: Insertion Sort.](https://reader030.fdocuments.net/reader030/viewer/2022020102/5697bfaf1a28abf838c9cfa0/html5/thumbnails/53.jpg)
COSC 3101, PROF. J. ELDER 53
f(i) = 1/i∑i=1..n f(i) = θ(log n)
n
Sum of Shrinking Function
![Page 54: Summations COSC 3101, PROF. J. ELDER 2 Recall: Insertion Sort.](https://reader030.fdocuments.net/reader030/viewer/2022020102/5697bfaf1a28abf838c9cfa0/html5/thumbnails/54.jpg)
COSC 3101, PROF. J. ELDER 54
Does the statement hold for the Harmonic Sum?
∑i=1..n 1/i = 1/1 + 1/2 + 1/3 + 1/4 + 1/5 + … + 1/n
∑i=1..n f(i)
= θ(n · f(n))
= ∑i=1..n 1/i = θ(log n)
θ(1) = θ(n · 1/n)≠
No the statement does not hold!
f(n) = nθ(1)-1 ∑i=1..n f(i) = θ(n·f(n))Arithmetic Like:
(1) 11n
n
![Page 55: Summations COSC 3101, PROF. J. ELDER 2 Recall: Insertion Sort.](https://reader030.fdocuments.net/reader030/viewer/2022020102/5697bfaf1a28abf838c9cfa0/html5/thumbnails/55.jpg)
COSC 3101, PROF. J. ELDER 55
Adding Made Easy
not included
![Page 56: Summations COSC 3101, PROF. J. ELDER 2 Recall: Insertion Sort.](https://reader030.fdocuments.net/reader030/viewer/2022020102/5697bfaf1a28abf838c9cfa0/html5/thumbnails/56.jpg)
COSC 3101, PROF. J. ELDER 56
∑i=1..n 1 = n · 1 = n · f(n)
Intermediate Case:
Lower Extreme: ∑i=1..n 1/i0.9999
= θ(n0.0001) = θ(n · f(n))
Upper Extreme: ∑i=1..n i1000 = 1/1001 n1001
= 1/1001 n · f(n)
f(n) = nθ(1)-1 ∑i=1..n f(i) = θ(n·f(n))Arithmetic Like:
![Page 57: Summations COSC 3101, PROF. J. ELDER 2 Recall: Insertion Sort.](https://reader030.fdocuments.net/reader030/viewer/2022020102/5697bfaf1a28abf838c9cfa0/html5/thumbnails/57.jpg)
COSC 3101, PROF. J. ELDER 57
Adding Made Easy
Done
![Page 58: Summations COSC 3101, PROF. J. ELDER 2 Recall: Insertion Sort.](https://reader030.fdocuments.net/reader030/viewer/2022020102/5697bfaf1a28abf838c9cfa0/html5/thumbnails/58.jpg)
COSC 3101, PROF. J. ELDER 58
Adding Made Easy
![Page 59: Summations COSC 3101, PROF. J. ELDER 2 Recall: Insertion Sort.](https://reader030.fdocuments.net/reader030/viewer/2022020102/5697bfaf1a28abf838c9cfa0/html5/thumbnails/59.jpg)
COSC 3101, PROF. J. ELDER 59
If the terms f(i) decrease towards zerosufficiently quickly,
then the sum will be a constant.
The classic example ∑i=0..n 1/2i = 1 + 1/2 + 1/4 + 1/8 + … < 2.
f(n) n-1-Ω(1) ∑i=1..n f(i) = θ(1)Bounded Tail:
![Page 60: Summations COSC 3101, PROF. J. ELDER 2 Recall: Insertion Sort.](https://reader030.fdocuments.net/reader030/viewer/2022020102/5697bfaf1a28abf838c9cfa0/html5/thumbnails/60.jpg)
COSC 3101, PROF. J. ELDER 60
Upper Extreme: ∑i=1..n 1/i1.0001
= θ(1)
No Lower Extreme:2i
∑i=1..n 22 = θ(1).
1
All functions in between.
f(n) n-1-Ω(1) ∑i=1..n f(i) = θ(1)Bounded Tail:
![Page 61: Summations COSC 3101, PROF. J. ELDER 2 Recall: Insertion Sort.](https://reader030.fdocuments.net/reader030/viewer/2022020102/5697bfaf1a28abf838c9cfa0/html5/thumbnails/61.jpg)
COSC 3101, PROF. J. ELDER 61
Adding Made Easy
Done
![Page 62: Summations COSC 3101, PROF. J. ELDER 2 Recall: Insertion Sort.](https://reader030.fdocuments.net/reader030/viewer/2022020102/5697bfaf1a28abf838c9cfa0/html5/thumbnails/62.jpg)
COSC 3101, PROF. J. ELDER 62
Summary
• Geometric Like: If f(n) 2Ω(n), then ∑i=1..n f(i) = θ(f(n)).
• Arithmetic Like: If f(n) = nθ(1)-1, then ∑i=1..n f(i) = θ(n · f(n)).
• Harmonic: If f(n) = 1/n , then ∑i=1..n f(i) = θ(logn).
• Bounded Tail: If f(n) n-1-Ω(1), then ∑i=1..n f(i) = θ(1).
(For +, -, , , exp, log functions f(n))
![Page 63: Summations COSC 3101, PROF. J. ELDER 2 Recall: Insertion Sort.](https://reader030.fdocuments.net/reader030/viewer/2022020102/5697bfaf1a28abf838c9cfa0/html5/thumbnails/63.jpg)
End of Lecture 3
March 11, 1009