HW2 Solution
HW2 Solution
HW2 Solution
4.2-3
How would you modify Strassen’s algorithm to multiply n*n matrices in which n
is not an exact power of 2? Show that the resulting algorithm runs in time
Suppose <n<N=
Since < n, it follows that N < 2n. Therefore, the runtime becomes
( ) ( )
4.3-2
We will use substitution method to verify the given solution. We start by trying
T (n) ≦ clg(⌈ ⌉) + 1
< clg(n/2 + 1) + 1
= clg( )+1
= clg(n + 2) - c + 1
This is inconclusive, so we will modify the solution a bit. We will try to prove
that T (n) ≦clg(n - b). Note that this still would imply that T (n) is O(lgn).
< clg(n/2- b + 1) + 1
= clg( )+1
≦clg(n - b)
The last inequality is true if b ≧ 2 and c ≧ 1. Note that this still does not work
4.3-6
So, T(m) ≤ cm lg m ∀ m ≤⌊ ⌋
≤ 2c ( ⌊ ⌋ )lg ( ⌊ ⌋)+n
≤ 2c (n/2+17)lg(n/2 +17) + n
= cn lg n + n(k+1-c lg 4/3)
k+1 – c lg 4/3 ≤ 0
k+1 ≤ c lg 4/3
c ≥ (k+1)/ lg(4/3) = k
T(n) ≤ cn lg n
4.4-5
∑
∑ ∑
Since
since
Let
4.5-1
Use the master method to give tight asymptotic bounds for the following
recurrences.
b. T(n) = 2T(n/4)+√
case2:
T(n) = aT(n/b)+f(n)
If f(n) = θ( o ba
) thenT(n) =θ( o ba
𝑙𝑔 )
a = 2, b = 4, f (n) =√
o 4
= = f(n)
So , T(n) = θ(√ 𝑙𝑔 )
4-3
Give asymptotic upper and lower bounds for T(n) in each of the following
b.
Solution 1
Let
∑ // harmonic sum
Thus
Solution 2
……
o
∑
o
∑
o
∑
∑o
d.
assume
= cn lg(n/3) + n/2
assume
1/2 - clg6 – k ≤ 0
1/2 – k ≤ clg6