You are on page 1of 6

Name: _______________________________________

TCSS 543 (simulation)

Midterm 1 Winter 2017

Q1 (out of 1)
Q2 (out of 4)
Q3 (out of 6)

m
Q4 (out of 9)

er as
co
Q5 (out of 10)

eH w
o.
Q6 (out of 5)
rs e
ou urc
Total (out of 30+5)
o
aC s
vi y re
ed d
ar stu
sh is
Th

https://www.coursehero.com/file/21311105/TCSS543A-midterm1-simulation/
1
Name: _______________________________________

1. (1 point) Write your name on every page.

2. (4 points) Sort the following functions in order of increasing asymptotic complexity. You must justify
each adjacent pair in your ordered list (use the limit test). Since the list has 5 functions, this means
you need to use the limit test for justification 4 times (1 point each).
 𝑓1 (𝑛) = 𝑎𝑛 , where 0 < 𝑎 < 1 is some constant.
 𝑓2 (𝑛) = 𝑛𝑛 .
 𝑓3 (𝑛) = 𝑛 𝑟√𝑛, where 𝑟 > 1 is some integer constant.
 𝑓4 (𝑛) = 𝑛2 / ln𝑐 𝑛, where 𝑐 > 0 is some integer constant.
 𝑓5 (𝑛) = 𝑛 ln𝑘 𝑛, where 𝑘 > 0 is some integer constant.

Solution: given the ordering is 𝑓1 < 𝑓5 < 𝑓3 < 𝑓4 < 𝑓2. Proof (applying L’Hôpital’s rule whenever needed
in the limit tests):

m
𝑓1 (𝑛) 𝑎𝑛

er as
 lim = lim = 0 because 𝑎 < 1.
𝑛→∞ 𝑓5 (𝑛) 𝑛→∞ 𝑛 ln𝑘 𝑛

co
𝑓 (𝑛) 𝑛 ln𝑘 𝑛 ln𝑘 𝑛 𝑘 ln𝑘−1 𝑛/𝑛 𝑟𝑘 ln𝑘−1 𝑛 𝑟𝑘(𝑘−1) ln𝑘−2 𝑛/𝑛
 lim 5 = lim 𝑛 𝑟 𝑛 = lim = lim = lim = lim =

eH w
1 1 1 1
𝑛→∞ 𝑓3 (𝑛) 𝑛→∞ √ 𝑛→∞ 𝑛𝑟 𝑛→∞ 1
( )𝑛𝑟
−1 𝑛→∞ 𝑛𝑟 𝑛→∞ 1
( )𝑛𝑟
−1
𝑟 𝑟

o.
𝑟 2 𝑘(𝑘−1) ln𝑘−2 𝑛 𝑟 𝑘 𝑘!
lim = ⋯ lim = 0.
𝑛→∞
rs e
1
𝑛𝑟
𝑛 𝑟√𝑛
𝑛→∞ 𝑛𝑟
1

𝑟
ou urc
𝑓3 (𝑛) √𝑛 ln𝑐 𝑛 ln𝑐 𝑛 𝑐!
 lim = lim = lim = lim 1 = ⋯ = lim 1 = 0.
𝑛→∞ 𝑓4 (𝑛) 𝑛→∞ 𝑛2 / ln𝑐 𝑛 𝑛→∞ 𝑛 𝑛→∞ 𝑛1−𝑟 𝑛→∞ (1−1)𝑐 𝑛1−𝑟
𝑟
𝑓4 (𝑛) 𝑛2 / ln𝑐 𝑛 1
 lim = lim = lim = 0.
𝑛→∞ 𝑓2 (𝑛) 𝑛𝑛 𝑛→∞ 𝑛𝑛−2 ln𝑐 𝑛
o

𝑛→∞
aC s

3. (6 points) Solve the following recurrences, where 𝑏 > 1 is some constant, using the Master Theorem.
vi y re

Indicate which case applies, what the value of 𝜀 is, and check the regularity condition as needed.
 𝑇(𝑛) = 𝑏 2 𝑇(𝑛/𝑏) + 𝑛.
 𝑇(𝑛) = 𝑏 2 𝑇(𝑛/𝑏) + 𝑛2.
ed d

 𝑇(𝑛) = 𝑏 2 𝑇(𝑛/𝑏) + 𝑛3.


ar stu

𝑏
 𝑇(𝑛) = 𝑇( √𝑛) + 1.
𝑏
 𝑇(𝑛) = 𝑏𝑇( √𝑛) + lg 𝑛.
 𝑇(𝑛) = 𝑇(𝑛 − lg 𝑏) + 𝑏.
sh is
Th

Solution:

 𝑐 = log 𝑏 𝑏 2 = 2, 𝑛 ∈ O(𝑛𝑐−𝜀 ) for 𝜀 = 1, hence 𝑇 ∈ Θ(𝑛2 ) by the 1st case.


 𝑐 = log 𝑏 𝑏 2 = 2, 𝑛2 ∈ Θ(𝑛𝑐 ) hence 𝑇 ∈ Θ(𝑛2 log 𝑛) by the 2nd case.
 𝑐 = log 𝑏 𝑏 2 = 2 , 𝑛3 ∈ Ω(𝑛𝑐+𝜀 ) for 𝜀 = 1 , 𝑏 2 𝑓(𝑛/𝑏) = 𝑏 2 (𝑛/𝑏)3 = (1/𝑏)𝑛3 ≤ 𝑑𝑓(𝑛) where
𝑑 = 1/𝑏 < 1, hence 𝑇 ∈ Θ(𝑛3 ) by the 3rd case.
𝑏
 Define 𝑛 ≔ 2𝑚 (i.e. 𝑚 = lg 𝑛 ) and 𝑆(𝑚) ≔ 𝑇(2𝑚 ) . Thus 𝑆(𝑚) = 𝑇(𝑛) = 𝑇( √𝑛) + 1 =
𝑇(2𝑚/𝑏 ) + 1 = 𝑆(𝑚/𝑏) + 1, hence 𝑆(𝑚) ∈ Θ(lg 𝑚) by the 2nd case, i.e. 𝑇(𝑛) = Θ(lg lg 𝑛).
𝑏
 Define 𝑛 ≔ 2𝑚 (i.e. 𝑚 = lg 𝑛 ) and 𝑆(𝑚) ≔ 𝑇(2𝑚 ) . Thus 𝑆(𝑚) = 𝑇(𝑛) = 𝑏𝑇( √𝑛) + lg 𝑛 =
𝑏𝑇(2𝑚/𝑏 ) + 𝑚 = 𝑏𝑆(𝑚/𝑏) + 𝑚 , hence 𝑆(𝑚) ∈ Θ(𝑚 lg 𝑚) by the 2nd case, i.e. 𝑇(𝑛) =
Θ(lg 𝑛 lg lg 𝑛).

https://www.coursehero.com/file/21311105/TCSS543A-midterm1-simulation/
2
Name: _______________________________________

 Define 𝑚 ≔ 2𝑛 (i.e. 𝑛 = lg 𝑚) and 𝑆(𝑚) ≔ 𝑇(lg 𝑚). Thus 𝑆(𝑚) = 𝑇(𝑛) = 𝑇(𝑛 − lg 𝑏) + 𝑏 =
𝑇(lg 𝑚 − lg 𝑏) + 𝑏 = 𝑇(lg(𝑚/𝑏)) + 𝑏 = 𝑆(𝑚/𝑏) + 𝑏, hence 𝑆(𝑚) ∈ Θ(lg 𝑚) by the 2nd case,
i.e. 𝑇(𝑛) ∈ Θ(𝑛).

4. (9 points, 3 points each) Let 𝐴[1 … 𝑛][1 … 𝑛] be an 𝑛 × 𝑛 real matrix. Denote by 𝐴[1 … 𝑖 − 1, 𝑖 +
1 … 𝑛][1 … 𝑗 − 1, 𝑗 + 1 … 𝑛] the (𝑛 − 1) × (𝑛 − 1) submatrix of 𝐴 obtained by deleting the 𝑖-th row
and the 𝑗-th column of 𝐴. The determinant of that submatrix is called the (𝑖, 𝑗)-minor of 𝐴, denoted
𝑀𝑖𝑗 , and the value 𝐶𝑖𝑗 = (−1)𝑖+𝑗 𝑀𝑖𝑗 is called the (𝑖, 𝑗)-cofactor of 𝐴.
The Laplace expansion computes the determinant of 𝐴 as det 𝐴 = 𝑑 if 𝐴 = [𝑑], i.e. if 𝑛 = 1, and as
det 𝐴 = ∑𝑛𝑘=1 𝐴𝑖𝑘 ⋅ 𝐶𝑖𝑘 for any fixed choice of 1 ≤ 𝑖 ≤ 𝑛 if 𝑛 > 1.
a. Express the Laplace expansion in pseudo-code as a recursive algorithm to compute
det 𝐴 from a given matrix 𝐴.

m
Solution:

er as
Laplace(𝐴[1 … 𝑛][1 … 𝑛])

co
If 𝑛 = 1 then

eH w
Return 𝐴[1,1]

o.
End if
rs e 𝑠=0
ou urc
For 𝑘 = 1 to 𝑛 do
// take 𝑖 = 1 for instance
o

𝑀 = Laplace(𝐴[2 … 𝑛][1 … 𝑘 − 1, 𝑘 + 1 … 𝑛])


aC s

𝑠 = 𝑠 + 𝐴[1, 𝑘] ∗ (−1)1+𝑘 ∗ 𝑀
vi y re

End for
Return 𝑠.
End Laplace
ed d

b. Obtain a recurrence 𝑇(𝑛) for the running time of your algorithm.


ar stu

Solution:
𝑐 if 𝑛 = 1
𝑇(𝑛) = {
𝑛𝑇(𝑛 − 1) + 𝑑𝑛 if 𝑛 > 1
sh is

where 𝑑 stands for the time needed to compute and update the summation inside the
Th

inner loop body (a larger cost might arise according to how the input to the recursive
call is prepared, but all this is actually small compared to the complexity of the recursive
calls themselves).
Here we assume 𝑓(𝑛) = 𝑑𝑛, which means constant time to execute the body of the
loop on 𝑘 (except for the recursive call), which is reasonable because the update of 𝑠 is
clearly linear, and the preparation of 𝐴[2 … 𝑛][1 … 𝑘 − 1, 𝑘 + 1 … 𝑛] can be carried out by
simply indicating which columns are omitted from 𝐴. However, the cost is never worse than
quadratic even if one uses a full copy of the elements on 𝐴[2 … 𝑛][1 … 𝑘 − 1, 𝑘 + 1 … 𝑛], and the
resulting complexity (item c below) will not be substantially affected.

https://www.coursehero.com/file/21311105/TCSS543A-midterm1-simulation/
3
Name: _______________________________________

c. State (by repeated substitution) and prove (by induction) a tight (big-Theta) asymptotic
𝑥𝑘
expression for 𝑇(𝑛). Hint: from the Taylor series 𝑒 𝑥 = ∑∞
𝑘=1 𝑘! we have the
1𝑘 1 1 1 1
approximation 𝑒 = 𝑒 1 = ∑∞
𝑘=1 𝑘! ≈ 1! + 2! + 3 ! + ⋯ + (𝑛−1)! for large 𝑛.

Solution:
By repeated substitution,
𝑇(𝑛) = 𝑛𝑇(𝑛 − 1) + 𝑑𝑛 = 𝑛((𝑛 − 1)𝑇(𝑛 − 2) + 𝑑(𝑛 − 1)) + 𝑑𝑛 =
𝑛(𝑛 − 1)𝑇(𝑛 − 2) + 𝑑𝑛(𝑛 − 1) + 𝑑𝑛 = 𝑛(𝑛 − 1)((𝑛 − 2)𝑇(𝑛 − 3) + 𝑑(𝑛 − 2)) +
𝑑𝑛(𝑛 − 1) + 𝑑𝑛 = 𝑛(𝑛 − 1)(𝑛 − 2)𝑇(𝑛 − 3) + 𝑑𝑛(𝑛 − 1)(𝑛 − 2) + 𝑑𝑛(𝑛 − 1) +
𝑑𝑛 = ⋯ = 𝑛(𝑛 − 1)(𝑛 − 2) … (𝑛 − 𝑘 + 3)(𝑛 − 𝑘 + 2)𝑇(𝑛 − 𝑘 + 1) +
𝑑𝑛(𝑛 − 1)(𝑛 − 2) … (𝑛 − 𝑘 + 3) + ⋯ + 𝑑𝑛(𝑛 − 1) + 𝑑𝑛 = ⋯ = 𝑛(𝑛 − 1)(𝑛 −
2) … (3)(2)𝑇(1) + 𝑑𝑛(𝑛 − 1)(𝑛 − 2) … (3) + ⋯ + 𝑑𝑛(𝑛 − 1) + 𝑑𝑛 = ⋯ = 𝑛! 𝑐 +
𝑑𝑛(𝑛 − 1)(𝑛 − 2) … (3)(2)/(2) + 𝑑𝑛(𝑛 − 1)(𝑛 − 2) … (3)(2)/(3)(2) + ⋯ +
𝑑𝑛(𝑛 − 1)(𝑛 − 2) … (3)(2)/(𝑛 − 1) … (3)(2) = 𝑛! 𝑐 + 𝑑𝑛!/2! + 𝑑𝑛!/3! + ⋯ +

m
er as
𝑑𝑛!/(𝑛 − 1)! = 𝑛! (𝑐 + 𝑑(1/2! + 1/3! + ⋯ + 1/(𝑛 − 1)!)) = 𝑛! (𝑐 − 𝑑 +

co
𝑑(1/1! + 1/2! + 1/3! + ⋯ + 1/(𝑛 − 1)!)) ≈ 𝑛! (𝑐 − 𝑑 + 𝑑𝑒).

eH w
Hence we guess that 𝑇(𝑛) ∈ Θ(𝑛!).

o.
rs e
Proof:
ou urc
Upper bound:
The naïve approach that 𝑇(𝑛) ≤ 𝑏 ⋅ 𝑛! will not work for 𝑛 > 1: 𝑇(𝑛) = 𝑛𝑇(𝑛 − 1) +
𝑑𝑛 ≤ 𝑛𝑏 ⋅ (𝑛 − 1)! + 𝑑(𝑛 − 1) ≤ 𝑏 ⋅ 𝑛! + 𝑑𝑛, but this fails to be ≤ 𝑏 ⋅ 𝑛!. Hence we
o

prove that 𝑇(𝑛) ≤ 𝑏 ⋅ 𝑛! + ℎ for some constant ℎ instead.


aC s

Base case 𝑛 = 1: 𝑇(𝑛) = 𝑇(1) = 𝑐 = 𝑐 ⋅ 1! = 𝑐 ⋅ 𝑛! ≤ 𝑏 ⋅ 𝑛! + ℎ as long as 𝑏 ≥ 𝑐 and


vi y re

any choice of ℎ.
Inductive hypothesis: 𝑇(𝑘) ≤ 𝑏 ⋅ 𝑘! + ℎ for any 1 ≤ 𝑘 < 𝑛.
Inductive step: for 𝑛 > 1: 𝑇(𝑛) = 𝑛𝑇(𝑛 − 1) + 𝑑𝑛 ≤ 𝑛(𝑏 ⋅ (𝑛 − 1)! + ℎ) + 𝑑(𝑛 − 1) =
𝑏 ⋅ 𝑛! + ℎ𝑛 + 𝑑(𝑛 − 1) ≤ 𝑏 ⋅ 𝑛! + ℎ. The last inequality holds as long as ℎ𝑛 + 𝑑𝑛 − 𝑑 ≤
ed d

ℎ for any 𝑛 > 1, i.e. (ℎ + 𝑑)(𝑛 − 1) ≤ 0 or simply ℎ ≤ −𝑑. Thus we choose 𝑏 = 𝑐, ℎ ≤


ar stu

−𝑑, and the upper bound 𝑇(𝑛) ≤ 𝑐 ⋅ 𝑛! − 𝑑 holds for all cases. □

Lower bound:
sh is

Base case 𝑛 = 1: 𝑇(𝑛) = 𝑇(1) = 𝑐 = 𝑐 ⋅ 1! = 𝑐 ⋅ 𝑛! ≥ 𝑎 ⋅ 𝑛! as long as 𝑎 ≤ 𝑐.


Inductive hypothesis: 𝑇(𝑘) ≥ 𝑎 ⋅ 𝑘! for any 1 ≤ 𝑘 < 𝑛.
Th

Inductive step: for 𝑛 > 1: 𝑇(𝑛) = 𝑛𝑇(𝑛 − 1) + 𝑑𝑛 ≥ 𝑛𝑎 ⋅ (𝑛 − 1)! + 𝑑(𝑛 − 1) = 𝑎 ⋅


𝑛! + 𝑑(𝑛 − 1) ≥ 𝑎 ⋅ 𝑛! for any choice of 𝑎. Therefore we choose 𝑎 = 𝑐 and the lower
bound 𝑇(𝑛) ≥ 𝑐 ⋅ 𝑛! holds for all cases. □

If we used a pessimistic 𝑓(𝑛) = 𝑑𝑛2 cost to prepare the recursive call instead, the guess
would become 𝑇(𝑛) ≈ 𝑛! (𝑐 + 𝑑(2𝑒 − 1)) − 𝑑𝑛 instead, which is still Θ(𝑛!).

5. (10 points) A connected, undirected graph 𝐺 = (𝑉, 𝐸) is called bipartite if 𝑉 can be split into two
disjoint sets 𝑉1 and 𝑉2 such that every edge in 𝐸 connects a vertex in 𝑉1 to a vertex in 𝑉2 . Consider
the following algorithm to test if a graph is bipartite: it returns a pair (𝑉1 , 𝑉2 ) such that 𝑉1 ∪ 𝑉2 = 𝑉
and 𝑉1 ∩ 𝑉2 = ∅ if 𝐺 is bipartite, and (∅, ∅) otherwise.

https://www.coursehero.com/file/21311105/TCSS543A-midterm1-simulation/
4
Name: _______________________________________

Bipartite(𝐺)
If #𝑉 ≤ 1 then
Return (𝑉1 , ∅)
End if
Remove a vertex 𝑢 from 𝑉.
Let 𝑊 = ∅
For all edges 𝑒 ∈ 𝐸 such that 𝑒 = (𝑢, 𝑣) for some 𝑣 do
Add 𝑣 to 𝑊
Remove 𝑒 from 𝐸
End for
Let 𝐺′ = (𝑉′, 𝐸′) be the resulting graph.
(𝑉1 , 𝑉2 ) = Bipartite(𝐺′)
If 𝑊 ⊆ 𝑉1 then
Return (𝑉1 , 𝑉2 ∪ {𝑢})

m
er as
Else if 𝑊 ⊆ 𝑉2 then
Return (𝑉1 ∪ {𝑢}, 𝑉2 )

co
eH w
Else
Return (∅, ∅)

o.
End if
End Bipartite rs e
ou urc
a. (5 points) Prove that this algorithm is correct. Hint: try proving by induction instead of
comparing the algorithm’s output with an oracle’s output.
o
aC s

Solution (by induction):


vi y re

Base case: If the graph has only one vertex 𝑢, that vertex is assigned to 𝑉1, no vertex is assigned to
𝑉2 , and the algorithm correctly returns ({𝑢}, ∅) which means “bipartite”.
Induction hypothesis: Assume that the algorithm is correct when presented with a graph with 1 ≤
𝑘 < 𝑛 vertices.
ed d

Inductive step: Let 𝑢 be the vertex removed from 𝐺 for the recursive call. The algorithm yields the
ar stu

correct answer (𝑉1 , 𝑉2 ) when applied to 𝐺′ because the number of nodes of 𝐺′ is less than 𝑛.
If 𝐺′ is bipartite, then 𝑉1 ∪ 𝑉2 = 𝑉 and 𝑉1 ∩ 𝑉2 = ∅. In that case, if the set 𝑊 of nodes that are
adjacent to 𝑢 is entirely contained in 𝑉1, then assigning 𝑢 to 𝑉2 preserves the bipartition and the
correct solution for 𝐺 is (𝑉1 , 𝑉2 ∪ {𝑢}), and if the set 𝑊 of nodes that are adjacent to 𝑢 is entirely
sh is

contained in 𝑉2 , then assigning 𝑢 to 𝑉1 preserves the bipartition and the correct solution for 𝐺 is
(𝑉1 ∪ {𝑢}, 𝑉2 ).
Th

Now if 𝐺′ is bipartite but the set 𝑊 of nodes adjacent to 𝑢 is not entirely contained in either 𝑉1 or
𝑉2 , then 𝑢 cannot be added to either 𝑉1 or 𝑉2 without violating the bipartition conditions, and hence
𝐺 is not bipartite. Finally, if 𝐺′ is not bipartite, then there is a vertex already in 𝐺′ that is adjacent to
any two sets 𝑉1 , 𝑉2 such that 𝑉1 ∪ 𝑉2 = 𝑉 and 𝑉1 ∩ 𝑉2 = ∅. Hence, adding back 𝑢 will not make the
result 𝐺 bipartite. □

b. (5 points) Find a big-Oh bound for the running time of this algorithm as a function of the
number of vertices 𝑛 and the number of edges 𝑚.

https://www.coursehero.com/file/21311105/TCSS543A-midterm1-simulation/
5
Name: _______________________________________

Solution: The complexity is given by a recurrence of form


𝑐, if 𝑛 ≤ 1
𝑇𝑚 (𝑛) = {
𝑇𝑚 (𝑛 − 1) + 𝑑𝑚, if 𝑛 > 1
where the linear term 𝑑𝑚 relates to the worst case complexity of the “for” loop scanning the edges
(all other operations in the algorithm except the recursive call take constant time and are
disregarded here). This recursion has the solution 𝑇𝑚 (𝑛) ∈ Θ(𝑛) as a function of 𝑛. Since the
running time is proportional to 𝑚, the complete complexity as a function of both 𝑛 and 𝑚 is Θ(𝑛𝑚).

6. (bonus question: 5 points) Let 𝑛 be a power of 3, i.e. 𝑛 = 3𝑘 for some 𝑘, let 𝜔 be a primitive 𝑛-th
root of unity, i.e. 𝜔𝑛 = 1 (but 𝜔𝑘 ≠ 1 for any 1 ≤ 𝑘 < 𝑛), and let 𝜁 be a primitive cubic root of
unity. Consider the following ternary version of the Cooley-Tukey algorithm for the FFT: split
polynomial
𝑎(𝑥) = 𝑎0 + 𝑎1 𝑥 + 𝑎2 𝑥 2 + ⋯ + 𝑎𝑛−1 𝑥 𝑛−1
into three parts as
𝑎(𝑥) = 𝑎[0] (𝑥 3 ) + 𝑥 ⋅ 𝑎[1] (𝑥 3 ) + 𝑥 2 ⋅ 𝑎[2] (𝑥 3 ),

m
er as
where
𝑎[0] (𝑥) = 𝑎0 + 𝑎3 𝑥 + 𝑎6 𝑥 2 + ⋯ + 𝑎𝑛−3 𝑥 𝑛−3 ,

co
eH w
𝑎[1] (𝑥) = 𝑎1 + 𝑎4 𝑥 + 𝑎7 𝑥 2 + ⋯ + 𝑎𝑛−2 𝑥 𝑛−2 ,
𝑎[2] (𝑥) = 𝑎2 + 𝑎5 𝑥 + 𝑎8 𝑥 2 + ⋯ + 𝑎𝑛−1 𝑥 𝑛−1 .

o.
Notice that 𝑎[0] (𝑥), 𝑎[1] (𝑥), 𝑎[2] (𝑥) have only 𝑛/3 coefficients each. Then compute these parts
rs e
at points (𝜔0 )3 , (𝜔1 )3 , (𝜔2 )3 , … (𝜔𝑛−1 )3 recursively, and combine the results as 𝑎(𝜔𝑘 ) =
ou urc
𝑎[0] (𝜔3 ) + 𝜔𝑘 ⋅ 𝑎[1] (𝜔3 ) + 𝜔2𝑘 ⋅ 𝑎[2] (𝜔3 ) , where the final combination of values takes linear
time. This yields the following algorithm stated in pseudo-code:
FFT3(𝑎[0 … 𝑛 − 1])
o

If 𝑛 = 1 then
aC s

Return 𝑎
vi y re

End if
𝑣 [0] =FFT3(𝑎[0] )
𝑣 [1] =FFT3(𝑎[1] )
ed d

𝑣 [2] =FFT3(𝑎[2] )
For 𝑘 = 0 to 𝑛/3 − 1 do
ar stu

[0] [1] [2]


𝑣𝑘 = 𝑣𝑘 + 𝜔𝑘 ⋅ 𝑣𝑘 + 𝜔2𝑘 ⋅ 𝑣𝑘
[0] [1] [2]
𝑣𝑘+𝑛/3 = 𝑣𝑘 + 𝜁 ⋅ 𝜔𝑘 ⋅ 𝑣𝑘 + 𝜁 2 ⋅ 𝜔2𝑘 ⋅ 𝑣𝑘
[0] [1] [2]
𝑣𝑘+2𝑛/3 = 𝑣𝑘 + 𝜁 2 ⋅ 𝜔𝑘 ⋅ 𝑣𝑘 + 𝜁 ⋅ 𝜔2𝑘 ⋅ 𝑣𝑘
sh is

End for
Return 𝑣.
Th

End FFT3

Find and prove a tight bound for the complexity of this algorithm as a function of 𝑛.

Solution: The complexity is given by a recurrence of form


𝑐, if 𝑛 ≤ 1
𝑇(𝑛) = { 𝑛
3𝑇 ( ) + 𝑑𝑛, if 𝑛 > 1
3
By the 2nd case of the Master Theorem, 𝑎 = 3, 𝑏 = 3, 𝑐 = log 𝑏 𝑎 = log 3 3 = 1, 𝑓(𝑛) = 𝑑𝑛 ∈ Θ(𝑛𝑐 ),
hence 𝑇(𝑛) ∈ Θ(𝑛 log 𝑛).

https://www.coursehero.com/file/21311105/TCSS543A-midterm1-simulation/
6

Powered by TCPDF (www.tcpdf.org)

You might also like