Chapter 4 Flashcards

1
Q

Use the following ideas to develop a nonrecursive, linear-time algorithm for the maximum-subarray problem. Start at the left end of the array, and progress toward the right, keeping track of the maximum subarray seen so far. Knowing a maximum subarray A[1..j], extend the answer to find a maximum subarray ending at indexj+1 by using the following observation: a maximum subarrayA[i..j+1], for some 1 ≤ i ≤ j+1. Determine a maximum subarray of the form A[i..j+1] in constant time based on knowing a maximum subarray ending at index j.

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

Pan has discovered a way of multiplying 68×68 matrices using 132464multiplications, a way of multiplying 70×70 matrices using 143640multiplications, and a way of multiplying 72×72 matrices using 155424 multiplications. Which method yields the best asymptotic running time when used in a divide-and-conquer matrix-multiplication algorithm? How does it compare to Strassen’s algorithm?

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

Show that the solution of T(n) = T(n - 1) + n is O(n2).

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

How quickly can you multiply a kn×n matrix by an n×kn matrix, using Strassen’s algorithm as a subroutine? Answer the same question with the order of the input matrices reversed.

A

kn×n)(n×kn) produces a kn×kn matrix. This produces k^2multiplications of n×n matrices.

(n×kn)(kn×n) produces an n×n matrix. This produces k multiplications and k−1 additions.

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

1Prove the following with substitution method: a. T(n) = 4T(n/2) + n^2 = Ω(n^2 lgn)

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

Solve by substitution

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

Recursion tree

A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q
A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q
A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q
A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Chapter 4 (5%). Find an asymptotic solution of the following recurrence. Express your answer using Θ-notation, and give a brief justification. 𝑇(𝑛) = 𝑙𝑜𝑔 𝑛 + 𝑇(√𝑛)

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

Use a recurrence tree to give an asymptotically tight solution to the recurrence T(n) = T(n-a) + T(a) + cn, where a ≥ 1 and c > 0 are constants.

A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q
  1. Suppose you know the solution of 𝑇(𝑛) = 5𝑇(𝑛/3) + 𝑛 is 𝑇(𝑛) = 𝛩(𝑛 𝑙𝑜𝑔3 5 ).
  • a. Show that a substitution proof with the assumption 𝑇(𝑛) ≤ 𝑐𝑛^𝑙𝑜𝑔3^5 fails.
  • b. Show how to subtract off a lower-order term to make a substitution proof work.
    *
A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q
A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q
A
17
Q
A
18
Q
A
19
Q

Show upper and lower bound

A
20
Q

Show upper and lower bound

A
21
Q

Show upper and lower bound

A
22
Q
A
23
Q
A
24
Q
A
25
Q
A
26
Q
A
27
Q
A
28
Q
A