Solutions for assignment 3
R-2.13 let c=3 and n0=1 then
2 * 2^n <= c * 2^n for all n>=n0
Thus according to the definition of Big-Oh 2^n+1 is O(2^n)
R-2.18 This is the summation from i = 1..n of the formula 5*(1/2^i)
which is 5 * ((summation from i = 0..n of (1/2^i)) - 1). Now the
the expansion of the summation is known ((1 - ((1/2)^n+1))/(1 - (1/2)))
(see book page 37). You can simplify more if you want to.
R-2.19 This is a simple one
3*((n * (n+1))/2) + 4n. You can simplify more if you want to.
R-2.22 It is O(n^2)
R-2.24 It is O(n^4) because roughly the inner and outer loop will both run
n^2 times. Thus their product will give you a n^4 asymptotic behavior.
C-2.4 Expand the summation into (n*(n+1)*(2n+1))/6 and then use the
proposition 7 in page 49 to state that (n^3+.....)/6 is O(n^3).
This is the easiest one. You can also prove it by induction on n.
C-2.9 a) The algorithm could look like
xpower = 1
result = a0
for i in n to 1
for j in 1 to i
xpower = xpower * x
end for j
result = result + a(i) * xpower
xpower = 1
end for i
b) n multiplications and additions thus it is a O(n) algorithm.
C-2.12 Let the statement be the proposition we try to prove. Thus F(n)
should be >= to c*(3/2)^n for c>=2/3
Base step (n=1, n=2): Then F(1)=1>=1, accordingly F(2)=2>=3/2.
Induction Hypothesis (n' < n): Assume that the statement holds true.
Induction Step : F(n) = F(n-1) + F(n-2) using the induction hypothesis
F(n) >= c(3/2)^(n-1) + c(3/2)^(n-2)
= c(3/2)^n * ((2/3) + (4/9))
(but ((2/3) + (4/9))= 10/9 > 1 thus)
F(n) > c(3/2)^n.
Hence, according to the principle of mathematical induction F(n) is
true, thus F(n) is big omega of (3/2)^n.