Master Theorem Flashcards

1
Q

Describe the Master Theorem formula:

A

T(n) = aT(n/b) + f(n) Where: a = how many subproblems n/b = size of each subproblem

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What is the master theorem time complexity for Karatsuba’s algorithm?

A

T(n) = 3T(n/2) + cn

  • n*logb a = nlog2 3n1.59
  • f(n)* = cn
  • cn* is O(n1.59-0.1)

T(n) is θ(nlog2 3)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is the master theorem time complexity for the Merge Sort algorithm?

A

T(n) = 2T(n/2) + cn

  • n*log2 2 = n
  • f(n)* = cn
  • cn* is θ(n)

T(n) is θ(n log n)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

We solve the recurrence of T(n) = aT(n/b) + f(n) by comparing ? with ?

A

f(n) is compared with nlogb a

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Master Theorem solutions - Case 1: if f(n) is much smaller than nlogb a then…

A

f(n) is O(nlogb a)
and
T(n) has time complexity nlogb a

if f(n) is O(nlogb a-e) for some e>0, then
T(n) = θ(nlogb a)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Master Theorem solutions - Case 2: if f(n) is the same as nlogb a then…

A

f(n) is θ(n<em>l</em>ogb a)
and
T(n) has time complexity nlogb a log n

T(n) = θ(nlogb a log n)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Master Theorem solutions - Case 3: if f(n) is much bigger than nlogb a then…

A

f(n) = Ω(nlogb a)
and
T(n) has time complexity f(n)

if f(n) is Ω(nlogb a+e) for some e>0,
and the regularity condition holds, then
T(n) = (f(n))

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What are the three cases when the Master Theorem doesn’t work?

A

when a < 1
T(n) = 0.5T(n/2) + n

when f(n) is negative
T(n) = 2T(n/2) - log n

When f(n) is smaller but not small enough:

  • f(n)* is O(nlogb a) but f(n) is not O(nlogba-e) for any e>0
  • T(n)* = 2T(n/2) + n/log n
How well did you know this?
1
Not at all
2
3
4
5
Perfectly