Sign in

Libre University uses your GitHub account. Signing in is only needed to sit a final test, so the score is kept on your profile.

Divide and conquer

1.[2p]

Why does the recursion tree for T(n)=2T(n/2)+n give Θ(nlogn)?

Correct
The answer is: Every level costs $n$ in total, and there are about $\log_2 n$ levels
The answer is: Every level costs $n$ in total, and there are about $\log_2 n$ levels
The answer is: Every level costs $n$ in total, and there are about $\log_2 n$ levels

2.[2p]

Put the three steps of divide and conquer in order.

  1. Conquer each instance by solving it recursively down to a base case

  2. Combine the sub-answers into an answer for the whole

  3. Divide the problem into smaller instances of the same problem

Show the answer

b, c, a

3.[2p]

How many comparisons does mergesort make in the worst case on 16 elements? Use nlog2n-n+1.

CorrectNot quite: 49

4.[2p]

For T(n)=aT(n/b)+f(n), the master theorem compares f(n) against

Correct
The answer is: $n^{\log_b a}$
The answer is: $n^{\log_b a}$
The answer is: $n^{\log_b a}$

5.[2p]

Naive block matrix multiplication obeys T(n)=8T(n/2)+Θ(n2). What exponent does the master theorem give for T(n)?

CorrectNot quite: 3

6.[3p]

In Karatsuba's method for 1234×5678 with a=12, b=34, c=56, d=78, the middle term is (a+b)(c+d)-ac-bd. What is it?

CorrectNot quite: 2840

7.[3p]

Karatsuba multiplication costs Θ(nlog23) rather than Θ(n2) because

Correct
The answer is: the middle term $ad + bc$ is obtained from one extra product rather than two
The answer is: the middle term $ad + bc$ is obtained from one extra product rather than two
The answer is: the middle term $ad + bc$ is obtained from one extra product rather than two

8.[3p]

Which are true of mergesort?

Select all that apply

Correct
Correct
Correct
The answer is: Its $\Theta(n \log n)$ bound holds in the worst case, not just on average, It is stable when the merge prefers the left run on ties, It normally needs $\Theta(n)$ extra memory

9.[2p]

Merging two sorted runs of four elements each takes at most how many comparisons?

CorrectNot quite: 7

10.[2p]

The master theorem settles every recurrence of the form T(n)=aT(n/b)+f(n).

The answer is: False
Correct