Algorithms 1 - M4

Pataasin ang iyong marka sa homework at exams ngayon gamit ang Quizwiz!

None of these answers

Select the best answer. At each call, Merge divides the problem in ______ subproblems. 5 3 None of these answers 4 2

2

Select the best answer. At each call, Merge-Sort divides the problem in ______ subproblems. 8 2 16 4 None of these answers

log x - log 2

Select the best answer. log (x/2) = _________________. Unless specified otherwise, log(n) is log base 2. log x - log 2 None of these answers log x / log 2 (log x ) / 2 log x + log 2

log x - log 4

Select the best answer. log (x/4) = _________________. Unless specified otherwise, log(n) is log base 2. log x + log 4 None of these answers log x - log 4 (log x ) / 4 log x / log 4

(log_b⁡(x))/(log_b(a))

Select the best answer. log_a(⁡x)= __________ where log_a is the logarithm base a. Recall than ln(x) is the natural logarithm and lg or log are logarithm base 2. [] ln⁡(x) [] (ln⁡(a))/(ln⁡(x)) [] None of these answers [] ln⁡(x/a) [] (log_b⁡(x))/(log_b(a))

(ln⁡(x))/(ln⁡(a))

Select the best answer. log_a(⁡x)= __________ where log_a is the logarithm base a. Recall that ln(x) is the natural logarithm and lg or log are logarithm base 2. [] (ln⁡(x))/(ln⁡(a)) [] ln⁡(x/a) [] None of these answers [] ln⁡(x) [] ln⁡(x)/lg⁡(x)

3

The divide-and-conquer involves _______ step(s) 4 None of these answers 3 1 2

16, 4, n, 1

We plan to use the Master Theorem to solve this recurrence relation: T(n) = 16T(n/4) + n. Using the Master theorem below, identify/match the parameters a, b, f(n), and the case that applies. Based on the Master Theorem, a = ____, b= ______, f(n) = _____, and the case that applies is _______(Provide only the case number 1, 2, or 3. If no case applies, provide the number 7). If a number is a fraction x/y, enter "x/y". Do not try to compute x/y.

e. None of these answers

We plan to use the Master Theorem to solve this recurrence relation: T(n) = 2T(n/2) + n log n. Using the Master theorem below, select the solution for the above recurrence relation. a. Theta(n log_2 n) b. Theta(n^2 log n) c. Theta(n^2) d. Theta(n) e. None of these answers

e. None of these answers

We plan to use the Master Theorem to solve this recurrence relation: T(n) = 2^nT(n/2) + n^n. Using the Master theorem below, select the solution for the above recurrence relation. a. Theta(n^2 log n) b. Theta(2^n) c. Theta(n^2) d. Theta(n) e. None of these answers

4, 2, cn, 1

We plan to use the Master Theorem to solve this recurrence relation: T(n) = 4T(n/2) + cn. Using the Master theorem below, identify/match the parameters a, b, f(n), and the case that applies. Based on the Master Theorem, a = ____, b= ______, f(n) = _____, and the case that applies is _______(Provide only the case number 1, 2, or 3. If no case applies, provide the number 7). If a number is a fraction x/y, enter "x/y". Do not try to compute x/y.

b. Theta(n^2)

We plan to use the Master Theorem to solve this recurrence relation: T(n) = 4T(n/2) + n / log n. Using the Master theorem below, select the solution for the above recurrence relation. a. Theta(log_2 n) b. Theta(n^2) c. Theta(n log_2 n) d. Theta(n^2 log_2 n) e. None of these answers

7, 2, n^2, 1

We plan to use the Master Theorem to solve this recurrence relation: T(n) = 7T(n/2) + n^2. Using the Master theorem below, identify/match the parameters a, b, f(n), and the case that applies. Based on the Master Theorem, a = _____, b= _____, f(n) = _____, and the case that applies is _______(Provide only the case number 1, 2, or 3. If no case applies, provide the number 7). If a number is a fraction x/y, enter "x/y". Do not try to compute x/y.

b. Theta(n^2)

We plan to use the Master Theorem to solve this recurrence relation: T(n) = 7T(n/3) + n^2 . Using the Master theorem below, select the solution for the above recurrence relation. a. Theta(log_2 (n)) b. Theta(n^2) c. Theta(n log_2 (n)) d. Theta(n^2 log_2 n) e. None of these answers

4

log_10(10^4) = ____ 10,000 9.21 3 None of these answers 4

5

log_2(32) = ____

5

log_b(b^5) = 5 None of these answers 5.b 5^b b

b

log_m(m^b) = ____

2

At each call, Merge-Sort divides the problem in ______ subproblems.

2

At each call, Merge-Sort divides the sequence in _______ sequences. 5 4 2 3 None of these answers

[] It calls Merge [] It divides the sequence in two subsequences at each step. [] It calls Merge-Sort [] It is recursive

Check all that apply. Check all that apply to the Merge-Sort algorithm. [] It calls Merge [] It divides the sequence in two subsequences at each step. [] It runs in O(n) [] It calls Merge-Sort [] It is recursive

Merge Sort Strassen's

Check all that apply. These algorithms use a divide-and-conquer strategy: [] Merge Sort [] Naïve sorting algorithm presented in previous modules [] Strassen's [] Insertion Sort

f1(n), f3(n), f4(n)

Consider the Merge procedure below. The running time of Merge belongs to f1(n), f2(n), f3(n), and/or f4(n) as defined below: f1(n) = theta(n) f2(n) = big O(log(n)) f3(n) = omega(n) f4(n) = big O(n^2)

f1(n), f2(n), f3(n)

Consider the Merge procedure below. The running time of Merge belongs to f1(n), f2(n), f3(n), and/or f4(n) as defined below: f1(n) = theta(n) f2(n) = omega(log log(n)) f3(n) = omega(log (n)) f4(n) = big O(log(n))

16

Consider the Merge procedure. MERGE(A, p, q, r) 1 n1 = q - p + 1 2 n2 = r - q 3 let L[1...n1 + 1] and R[1...n2 + 1] be new arrays 4 for i = 1 to n1 5 L[i] = A[p + i - 1] 6 for j = 1 to n2 7 R[j] = A[q + j] 8 L[n1 + 1] = infinity 9 R[n2 + 1] = infinity 10 i = 1 11 j = 1 12 for k = p to r 13 if L[i] R[j] 14 A[k] = L[i] 15 i = i + 1 16 else A[k] = R[j] 17 j = j + 1 If we call Merge(A, 10, 19,25), the body of the for-loop at Line 12 will run ____ times.

10

Consider the Merge procedure. MERGE(A, p, q, r) 1 n1 = q - p + 1 2 n2 = r - q 3 let L[1...n1 + 1] and R[1...n2 + 1] be new arrays 4 for i = 1 to n1 5 L[i] = A[p + i - 1] 6 for j = 1 to n2 7 R[j] = A[q + j] 8 L[n1 + 1] = infinity 9 R[n2 + 1] = infinity 10 i = 1 11 j = 1 12 for k = p to r 13 if L[i] R[j] 14 A[k] = L[i] 15 i = i + 1 16 else A[k] = R[j] 17 j = j + 1 If we call Merge(A, 10, 19,25), the body of the for-loop at Line 4 will run ____ times.

6

Consider the Merge procedure. MERGE(A, p, q, r) 1 n1 = q - p + 1 2 n2 = r - q 3 let L[1...n1 + 1] and R[1...n2 + 1] be new arrays 4 for i = 1 to n1 5 L[i] = A[p + i - 1] 6 for j = 1 to n2 7 R[j] = A[q + j] 8 L[n1 + 1] = infinity 9 R[n2 + 1] = infinity 10 i = 1 11 j = 1 12 for k = p to r 13 if L[i] R[j] 14 A[k] = L[i] 15 i = i + 1 16 else A[k] = R[j] 17 j = j + 1 If we call Merge(A, 10, 19,25), the body of the for-loop at Line 6 will run ____ times.

11

Consider the Merge procedure. MERGE(A, p, q, r) 1 n1 = q - p + 1 2 n2 = r - q 3 let L[1...n1 + 1] and R[1...n2 + 1] be new arrays 4 for i = 1 to n1 5 L[i] = A[p + i - 1] 6 for j = 1 to n2 7 R[j] = A[q + j] 8 L[n1 + 1] = infinity 9 R[n2 + 1] = infinity 10 i = 1 11 j = 1 12 for k = p to r 13 if L[i] R[j] 14 A[k] = L[i] 15 i = i + 1 16 else A[k] = R[j] 17 j = j + 1 If we call Merge(A, 10, 19,25), the left subsequence L has __________ elements.

7

Consider the Merge procedure. MERGE(A, p, q, r) 1 n1 = q - p + 1 2 n2 = r - q 3 let L[1...n1 + 1] and R[1...n2 + 1] be new arrays 4 for i = 1 to n1 5 L[i] = A[p + i - 1] 6 for j = 1 to n2 7 R[j] = A[q + j] 8 L[n1 + 1] = infinity 9 R[n2 + 1] = infinity 10 i = 1 11 j = 1 12 for k = p to r 13 if L[i] R[j] 14 A[k] = L[i] 15 i = i + 1 16 else A[k] = R[j] 17 j = j + 1 If we call Merge(A, 10, 19,25), the right subsequence R has __________ elements.

L, A, R

Consider the Merge procedure. MERGE(A, p, q, r) 1 n1 = q - p + 1 2 n2 = r - q 3 let L[1...n1 + 1] and R[1...n2 + 1] be new arrays 4 for i = 1 to n1 5 L[i] = A[p + i - 1] 6 for j = 1 to n2 7 R[j] = A[q + j] 8 L[n1 + 1] = infinity 9 R[n2 + 1] = infinity 10 i = 1 11 j = 1 12 for k = p to r 13 if L[i] R[j] 14 A[k] = L[i] 15 i = i + 1 16 else A[k] = R[j] 17 j = j + 1 Merge will modify/initialize these sequences. n1 n2 L A R

T(n) = 2 T(n/2) + 5.n

Consider the code of Merge-Sort Merge-Sort(A, p, r) if (p < r) q = floor((p+q)/2) Merge-Sort(A, p, q) Merge-Sort(A, q+1, r) Merge(A, p, q, r) If T(n) is the running time of Merge-Sort for an n size input, then the relation recurrence is for n > 1 is _________________ if the running time for Merge is 5.n. None of these answers T(n) = T(n/2) + c.n T(n) = 2 T(n/2) + 5.n T(n) = 2 T(n/2) + c.n T(n) = T(n/2) + 5.n

[] T(n) = 2 T(n/2) + 5.n

Consider the code of Merge-Sort Merge-Sort(A, p, r) if (p < r) q = floor((p+q)/2) Merge-Sort(A, p, q) Merge-Sort(A, q+1, r) Merge(A, p, q, r) If T(n) is the running time of Merge-Sort for an n size input, then the relation recurrence is for n > 1 is _________________ if the running time for Merge is 5.n. [] T(n) = T(n/2) + c.n [] T(n) = T(n/2) + 5.n [] None of these answers [] T(n) = 2 T(n/2) + 5.n [] T(n) = 2 T(n/2) + c.n

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

Consider the code of Merge-Sort: Merge-Sort(A, p, r) if (p < r) q = floor((p+q)/2) Merge-Sort(A, p, q) Merge-Sort(A, q+1, r) Merge(A, p, q, r) If T(n) is the running time of Merge-Sort for an n size input, then the relation recurrence is for n > 1 is _________________ if the running time for Merge is f(n). T(n) = 2 T(n/2) + f(n) T(n) = 2 T(n/2) + c.n T(n) = 2 T(n/2) + 5.n None of these answers T(n) = T(n/2) + f(n)

2T(16) + 96

Consider the following recurrence relation: T(n) = c. if n=1 2T(n/2) + cn. if n>1 Let c be 3, then T(32) = _____ 2T(16) + 32 2T(16) + 96 None of these answers T(16) + 96 T(16) + 64

12

Consider the following recurrence relation: T(n) = c. if n=1 2T(n/2) + cn. if n>1 Let c be 3. If we expand T(2), then T(2) = _____

4

Consider the following recurrence relation: T(n) = c. if n=1 2T(n/2) + cn. if n>1 When developing the recurrence tree, the 3rd level ("3rd call") has __________ nodes

2^(i-1)

Consider the following recurrence relation: T(n) = c. if n=1 2T(n/2) + cn. if n>1 When developing the recurrence tree, the ith level ("ith call") has __________ nodes. None of these answers 2^(i-1) 2^i 2^(i+1) 2^(i-2)

5.n

Consider the following recurrence relation: T(n) = c. if n=1 2T(n/2) + cn. if n>1 When developing the recurrence tree, the sum of the costs of all nodes at the ith level ("ith call") is ____________ when c = 5. 2^(5.n) 5 n 5.n None of these answers

5.n

Consider the following recurrence relation: T(n) = c. if n=1 2T(n/2) + cn. if n>1 When developing the recurrence tree, the sum of the costs of all nodes at the third level ("third call") is ____________ when c = 5. None of these answers 2^(5.n) 5 5.n n

4

Consider the following recurrence relation: T(n) = { c if n = 1 2T(n/2)+cn if n>1 Let c be 4, then T(1) =____ n c.n 4 4.n None of these answers

1

Consider the following recurrence relation: T(n) = { c if n = 1 2T(n/2)+cn if n>1 When developing the recurrence tree, the 1st level ("1st call") has __________ nodes

200.n.log n

Consider the recurrence relation: T(n) = 2.T(n/2) + 200n. A good guess could be _________________. Unless specified otherwise, log(n) is log base 2. 100.n.log n 100log n n.log n None of these answers 200.n.log n

4.n.(log n - 1)+4.n

Consider the recurrence relation: T(n) = 2.T(n/2) + 4.n. John guesses that T(n) = 4.n.log(n). Substituting T(n/2) by the guess in the recurrence relation will lead to T(n) = ______________. Unless specified otherwise, log(n) is log base 2. 2.n.(log n - log 2)+2.n None of these answers 2.n.(log n - log 2)+4.n 4.n.(log n - log 2)+2.n 4.n.(log n - 1)+4.n

None of these answers

Consider the recurrence relation: T(n) = 2.T(n/2) + 4.n. John guesses that T(n) = 4.n.log(n). Substituting T(n/2) by the guess in the recurrence relation will lead to T(n) = ______________. Unless specified otherwise, log(n) is log base 2. 2.n.log n - 4.n + 2.n 2.n.log n - 2.n + 2.n None of these answers 2.n.log n +2.n 4.n.log n - 2.n +4.n

4.n.log n - 4n + 4.n

Consider the recurrence relation: T(n) = 2.T(n/2) + 4.n. John guesses that T(n) = 4.n.log(n). Substituting T(n/2) by the guess in the recurrence relation will lead to T(n) = ______________. Unless specified otherwise, log(n) is log base 2. 4.n.(log n - 1)+2.n 2.n.(log n - 2)+2.n 2.n.log n +2.n 4.n.log n - 4n + 4.n None of these answers

4.n.log(n/2)+4.n

Consider the recurrence relation: T(n) = 2.T(n/2) + 4.n. John guesses that T(n) = 4.n.log(n). Substituting T(n/2) by the guess in the recurrence relation will yield T(n) = ______________. Unless specified otherwise, log(n) is log base 2. 4.n.log(n)-4.n 4.n.log(n/2)+4.n 4.n.log(n/2)-4.n None of these answers 2.n.log(n/2)

7.n.log n

Consider the recurrence relation: T(n) = 2.T(n/2) + 7.n. A good guess could be _________________. Unless specified otherwise, log(n) is log base 2. 7.log n 4.n.log n 7.n.log n None of these answers n.log n

recursive

Divide-and-conquer strategy uses _____________ algorithms. [] divisive [] iterative [] None of these answers [] recursive [] procedural


Kaugnay na mga set ng pag-aaral

real estate practice ( missed questions pt2)

View Set

business 101 pt 2 welcome to hell

View Set

patho immune and abnormal responses

View Set

Standard Form of Linear Equations, Standard Form of Linear Equations, Linear equation forms, Slope and Slope Intercept Form, Point-slope form

View Set

L/A/H Insurance . C5.Life Insurance Policy Provisions . Questions

View Set