M5

¡Supera tus tareas y exámenes ahora con Quizwiz!

Consider the algorithm Fibonacci(n) that computes Fibonacci numbers. Let A(n) be the number of additions necessary to compute Fibonacci(n). For n> 5, the ratio A(n+1)/A(n) is about __________.(in green)

1

Consider this table that provides the prices of a rod based on its length. length i 1 2 3 4 price pi 1 5 8 9 Suppose you have a rod R of length 5. Fill in this table with the total revenue based on the different ways the rod R is cut. We denote a decomposition into pieces using ordinary additive notation, so that 7 = 2 + 2 + 3 indicates that a rod of length 7 is cut into three pieces—two of length 2 and one of length 3. Suppose you have a rod R of length 3. Fill in this table with the total revenue based on the different ways the rod R is cut. We denote a decomposition into pieces using ordinary additive notation, so that 7 = 2 + 2 + 3 indicates that a rod of length 7 is cut into three pieces—two of length 2 and one of length 3.

1+2+2=11, 1+1+3=10, 1+1+1+2=8, 2+3=13 No cut=8, 2+1=6, 1+2=6, 1+1+1=3

This question is about how the output of Extended-Bottom-Up-Cut-Rod algorithm. The Extended-Bottom-Up-Cut-Rod algorithm delivers the following (r,s) output: i 0 1 2 3 4 5 6 7 8 9 10 r[i] 0 1 5 8 10 13 17 18 22 25 30 s[i] 0 1 2 3 2 2 6 1 2 3 10 This output produces the solution, i.e., the lengths of all cuts. The following algorithm displays the lengths. You must provide the list of the lengths of pieces based on the output (r,s) (see above). Suppose, you execute PRINT-CUT-ROD-SOLUTION(p, 7). Fill in the blanks in the order PRINT-CUT-ROD-SOLUTION(p,7) would. If there are more columns than pieces, fill in the entry with 99. You must provide the list of the lengths of pieces based on the output (r,s) (see above). Suppose, you execute PRINT-CUT-ROD-SOLUTION(p, 4). Fill in the blanks in the order PRINT-CUT-ROD-SOLUTION(p, 4) would. If there are more columns than pieces, fill in the entry with 99. You must provide the list of the lengths of pieces based on the output (r,s) (see above). Suppose, you execute PRINT-CUT-ROD-SOLUTION(p, 6). Fill in the blanks in the order PRINT-CUT-ROD-SOLUTION(p,6) would. If there are more columns than pieces, fill in the entry with 99. You must provide the list of the lengths of pieces based on the output (r,s) (see above). Suppose, you execute PRINT-CUT-ROD-SOLUTION(p, 10). Fill in the blanks in the order PRINT-CUT-ROD-SOLUTION(p,10) would. If there are more columns than pieces, fill in the entry with 99. You must provide the list of the lengths of pieces based on the output (r,s) (see above). Suppose, you execute PRINT-CUT-ROD-SOLUTION(p, 8). Fill in the blanks in the order PRINT-CUT-ROD-SOLUTION(p,8) would. If there are more columns than pieces, fill in the entry with 99. You must provide the list of the lengths of pieces based on the output (r,s) (see above). Suppose, you execute PRINT-CUT-ROD-SOLUTION(p, 5). Fill in the blanks in the order PRINT-CUT-ROD-SOLUTION(p,5) would. If there are more columns than pieces, fill in the entry with 99. You must provide the list of the lengths of pieces based on the output (r,s) (see above). Suppose, you execute PRINT-CUT-ROD-SOLUTION(p, 9). Fill in the blanks in the order PRINT-CUT-ROD-SOLUTION(p,9) would. If there are more columns than pieces, fill in the entry with 99.

1, 6, 99 2, 2, 99 6, 99, 99 10, 99, 99 2, 6, 99 2, 3, 99 3, 6, 99

Consider the algorithm Fibonacci(n) that computes Fibonacci numbers. Let A(n) be the number of additions necessary to compute Fibonacci(n). For n> 5, the ratio A(n+1)/A(n) is about __________.

1.6

Consider the algorithm Fibonacci(n) that computes Fibonacci numbers. Let A(n) be the number of additions necessary to compute Fibonacci(n). For n> 5, the ratio A(n+1)/A(n) is about __________.(in gray)

1.6

Consider the algorithm Fibonacci(n) that computes Fibonacci numbers. Let A(n) be the number of additions necessary to compute Fibonacci(n). The ratio A(6)/A(5) is about _________

1.6

Consider the algorithm Fibonacci(n) that computes Fibonacci numbers. Let A(n) be the number of additions necessary to compute Fibonacci(n). The ratio A(6)/A(5) is about __________.

1.6

Consider the algorithm Fibonacci(n) that computes Fibonacci numbers. Let A(n) be the number of additions necessary to compute Fibonacci(n). The ratio A(7)/A(6) is about _________

1.6

Consider the algorithm Fibonacci(n) that computes Fibonacci numbers. Let A(n) be the number of additions necessary to compute Fibonacci(n). The ratio A(7)/A(6) is about __________.

1.6

A rod of length 11'' could be cut in any number of pieces (Rod lengths are always an integral number of inches). There are in total ________ ways to cut such a 11'' rod.

1024

The total number of calls to CUT-ROD(p,n) to compute CUT-ROD(p, 10) is _____.

1024

A rod of length 8'' could be cut in any number of pieces (Rod lengths are always an integral number of inches). There are in total ________ ways to cut such a 8'' rod.

128

This question is about how the output of Extended-Bottom-Up-Cut-Rod algorithm. The Extended-Bottom-Up-Cut-Rod algorithm delivers the following (r,s) output: i 0 1 2 3 4 5 6 7 8 9 10 r[i] 0 1 5 8 10 13 16 18 21 24 26 s[i] 0 1 2 3 2 2 3 2 2 3 2 This output produces the solution, i.e., the lengths of all cuts. The following algorithm displays the lengths. You must provide the list of the lengths of pieces based on the output (r,s) (see above). Suppose, you execute PRINT-CUT-ROD-SOLUTION(p, 7). Fill in the blanks in the order PRINT-CUT-ROD-SOLUTION(p,7) would. If there are more columns than pieces, fill in the entry with 99. You must provide the list of the lengths of pieces based on the output (r,s) (see above). Suppose, you execute PRINT-CUT-ROD-SOLUTION(p, 6). Fill in the blanks in the order PRINT-CUT-ROD-SOLUTION(p,6) would. If there are more columns than pieces, fill in the entry with 99. You must provide the list of the lengths of pieces based on the output (r,s) (see above). Suppose, you execute PRINT-CUT-ROD-SOLUTION(p, 5). Fill in the blanks in the order PRINT-CUT-ROD-SOLUTION(p,5) would. If there are more columns than pieces, fill in the entry with 99. You must provide the list of the lengths of pieces based on the output (r,s) (see above). Suppose, you execute PRINT-CUT-ROD-SOLUTION(p, 8). Fill in the blanks in the order PRINT-CUT-ROD-SOLUTION(p,8) would. If there are more columns than pieces, fill in the entry with 99. You must provide the list of the lengths of pieces based on the output (r,s) (see above). Suppose, you execute PRINT-CUT-ROD-SOLUTION(p, 4). Fill in the blanks in the order PRINT-CUT-ROD-SOLUTION(p, 4) would. If there are more columns than pieces, fill in the entry with 99. You must provide the list of the lengths of pieces based on the output (r,s) (see above). Suppose, you execute PRINT-CUT-ROD-SOLUTION(p, 9). Fill in the blanks in the order PRINT-CUT-ROD-SOLUTION(p,9) would. If there are more columns than pieces, fill in the entry with 99.

2, 2, 3 3, 3, 99 2, 3, 99 2, 3, 3 2, 2, 99 3, 3, 3

Consider this table that provides the prices of a rod based on its length. length i 1 2 3 4 5 6 7 8 9 10 price pi 1 5 8 9 10 17 17 20 24 30 Suppose you have a rod R of length 9. We denote a decomposition into pieces using ordinary additive notation, so that 7 = 2 + 2 + 3 indicates that a rod of length 7 is cut into three pieces—two of length 2 and one of length 3. What is the total revenue of the decomposition 9 = 2 + 3 + 4 ? What is the total revenue of the decomposition 9 = 1 + 1 + 3 + 4 ? Suppose you have a rod R of length 8. We denote a decomposition into pieces using ordinary additive notation, so that 7 = 2 + 2 + 3 indicates that a rod of length 7 is cut into three pieces—two of length 2 and one of length 3. What is the total revenue of the decomposition 8 = 4 + 4? What is the total revenue of the decomposition 8 = 2+ 2 + 4?

22 19 18 19

Consider the algorithm Fibonacci(n) that computes Fibonacci numbers. Suppose that Fibonacci(10) and Fibonacci(11) require 88 and 143 additions, respectively. Then Fibonacci(12) will require ____________ additions.

232

A rod of length 9'' could be cut in any number of pieces (Rod lengths are always an integral number of inches). There are in total ________ ways to cut such an 9'' rod.

256

Consider the memoized algorithm Fibonacci(n) that computes Fibonacci numbers. Fibonacci(4) will require __________ additions

3

A rod of length 6'' could be cut in any number of pieces (Rod lengths are always an integral number of inches). There are in total ________ ways to cut such a 6'' rod.

32

Consider the algorithm Fibonacci(n) that computes Fibonacci numbers. Fibonacci(4) will require ____________ additions.

4

Consider this memoized algorithm Fibonacci(n) that computes Fibonacci numbers. Fibonacci(4) will require ____________ additions.

4

A rod of length 10'' could be cut in any number of pieces (Rod lengths are always an integral number of inches). There are in total ________ ways to cut such a 10'' rod.

512

Consider the algorithm Power(x, n). Power(2,6) will require __________ multiplications

6

Consider the algorithm Power(x,n) below. Power(2,64) will require ____________ multiplications.

6

Consider this memoized algorithm Fibonacci(n) that computes Fibonacci numbers. Fibonacci(6) will require ____________ additions.

6

A rod of length 7'' could be cut in any number of pieces (Rod lengths are always an integral number of inches). There are in total ________ ways to cut such an 7'' rod.

64

Consider the algorithm Power(x, n). Power(2, 6) will return

64

Consider the algorithm Power(x,n) below. Power(2,7) will require ____________ multiplications.

7

Consider this memoized algorithm Fibonacci(n) that computes Fibonacci numbers. Fibonacci(7) will require ____________ additions.

7

Consider the algorithm Power(x,n) below. Power(2,6) will return ____________.

8

Consider the algorithm Power(x,n) below. Power(2,8) will require ____________ multiplications.

8

Consider this memoized algorithm Fibonacci(n) that computes Fibonacci numbers. Fibonacci(8) will require ____________ additions.

8

Consider the algorithm Fibonacci(n) that computes Fibonacci numbers. Suppose that Fibonacci(13) and Fibonacci(14) require 376 and 609 additions, respectively. Then Fibonacci(15) will require _________ additions

986

Consider the algorithm Power(x, n). Power(2, 1000) will require _________ multiplications

999

Consider the algorithm Power(x,n) below. Power(2,1000) will require ____________ multiplications.

999

Dynamic programming would involve these steps in order to find the value of some optimal solution:

Characterize the structure of an optimal solution, Recursively define the value of an optimal solution, Compute the value of an optimal solution

Dynamic programming would involve these steps in order to deliver an optimal solution:

Characterize the structure of an optimal solution, build an optimal solution from the computer information, Recursively define the value of an optimal solution, Compute the value of an optimal solution

Dynamic programming would help with the following problems.

Fibonacci numbers computation, Rod-Cutting problem

Check all that apply to the MEMOIZED-CUT-ROD(p,n) algorithm.

It computes the maximal revenue for an optimal solution, It avoids recomputing the same subproblem, It is a recursive algorithm, It achieves a much better time complexity (Θ(n2)) than the simple recursive algorithm.

Check all that apply to the EXTENDED-BOTTOM-UP-CUT-ROD(p,n) algorithm.

It computes the maximal revenue for an optimal solution, It is an iterative algorithm, It achieves a much better time complexity (Θ(n2)) than the simple recursive algorithm, It avoids recomputing the same subproblem, It delivers the list of lengths of the cuts to achieve the maximal revenue

Check all that apply to the BOTTOM-UP-CUT-ROD(p,n) algorithm.

It computes the maximal revenue for an optimal solution, It is an iterative algorithm, It avoids recomputing the same subproblem, It achieves a much better time complexity (Θ(n2)) than the simple recursive algorithm. It is a memoized algorithm, it uses a dynamic programming approach, it solves the problems from the smallest to the largest

Check all that apply about the algorithms Algorithm I and Algorithm II on the table below: Algorithm I Algorithm II Power(x, n) Power(x, n) if (n == 0) p =1 return 1 for i = 1 to n return (x*Power(x,n-1)) p = x * p return p

They require the same number of multiplications, Algorithm II is more efficient than Algorithm I

Dynamic programming consists of _______________.

computing first smaller problems and use them immediately to solve larger ones, using memoization

Check all that apply about the algorithm Fibonacci(n)

inefficient, naive, recursive, simple

Check all that apply about the algorithm Power(x, n)

iterative, naive, simple

Consider the memoized rod-cutting algorithm: For each call to MEMOIZED-CUT-ROD-AUX(p, n, r), Line 7 is executed _______ time(s). Overall (in total), Line 8 (in MEMOIZED-CUT-ROD-AUX) is executed about _______ time(s) to execute MEMOIZED-CUT-ROD(p, n). Overall (in total), Line 2 (in MEMOIZED-CUT-ROD-AUX) is executed about _______ time(s) to execute MEMOIZED-CUT-ROD(p, n). Line ________ is used to reuse a previously computed value of an optimal solution. Overall (in total), Line 7 (in MEMOIZED-CUT-ROD-AUX) is executed _______ time(s) to execute MEMOIZED-CUT-ROD(p, n).

n n Θ(n2) 2 n(n+1)2

Consider the bottom-up rod-cutting algorithm: Overall (in total), Line 7 is executed about _______ time(s). Overall (in total), Line 6 is executed about _______ time(s). Overall (in total), Line 2 is executed about _______ time(s).

n n(n+1)2 none

Consider the extended bottom-up rod-cutting algorithm: Overall (in total), Line 9 is executed about _______ time(s). Overall (in total), The time complexity of EXTENDED-BOTTOM-UP-CUT-ROD is ______. Overall (in total), the test in Line 6 is executed about _______ time(s). The time complexity of Lines 6-8 is ______. Overall (in total), Line 10 is executed about _______ time(s). Overall (in total), Line 2 is executed about _______ time(s).

n2 Θ(n2) n(n+1)2 none none none

Let T(n) be the number of calls to CUT-ROD to compute the maximal revenue using CUT-ROD(p,n). The recurrence relation of T(n) is ________.

none

In order to answer this question, you must draw the recursion tree for CUT-ROD(p,n) for n = 5. Based, on the recursion tree for n = 5, the subproblem for n = 1 is computed ________ time(s). Based, on the recursion tree for n = 5, the subproblem for n = 2 is computed ________ time(s). Based, on the recursion tree for n = 5, the subproblem for n = 0 is computed ________ time(s).

none 4 16

Consider this table that provides the prices of a rod based on its length. length i 1 2 3 4 5 6 7 8 9 10 price pi 1 5 8 9 10 17 17 20 24 30 Using the notations pi and rn defined in the lecture, r9 = _________. Using the notations pi and rn defined in the lecture, r8 = _________. Suppose you have a rod R of length 9. Suppose that you can cut the rod in only two pieces (you can make only one cut). The maximal revenue you can achieve with one cut only is _________. Suppose you have a rod R of length 8. Suppose that you can cut the rod in only two pieces (you can make only one cut). The maximal revenue you can achieve with one cut only is _________. Using the notations pi and rn defined in the lecture, r7 = _________. Suppose you have a rod R of length 7. Suppose that you can cut the rod in only two pieces (you can make only one cut). The maximal revenue you can achieve with one cut only is _________. Using the notations pi and rn defined in the lecture, r6 = _________. Suppose you have a rod R of length 5. Suppose that you can cut the rod in only two pieces (you can make only one cut). The maximal revenue you can achieve with one cut only is _________. Suppose that you can cut the rod in only two pieces (you can make only one cut). We denote a decomposition into pieces using ordinary additive notation, so that 7 = 2 + 2 + 3 indicates that a rod of length 7 is cut into three pieces—two of length 2 and one of length 3. Show the decomposition that would yield the maximal revenue by cutting a rod of length n. Start with the piece of smallest size: n = 7 = n = 5 = n = 9 = n = 8 = Using the notations pi and rn defined in the lecture, r4 = _________. Using the notations piand rn defined in the lecture, r2 = ________. Using the notations piand rn defined in the lecture, r10 = _________.

r3+r6 r2+r6 25 22 r2+r2+r3 or r1+r6 18 p6 13 1+6 2+3 3+6 2+6 r2+r2 p2 r4+r6

Memoization consists of ______________.

storing the values of computed solutions and reuse them.

Check all that apply to this CUT-ROD(p,n) algorithm.

subproblems with overlapping computations, Simple, excessive repetitions of computations, wasteful computations

Consider the algorithm Fibonacci(n) that computes Fibonacci numbers. The time complexity of this algorithm is

Θ(φn) where φ is the Golden Ratio

Consider the algorithm Fibonacci(n) that computes Fibonacci numbers. The time complexity of this algorithm is _______.

Θ(φn) where φ is the Golden Ratio


Conjuntos de estudio relacionados

Chapter 2: Evolution of Selling Models That Compliment the Marketing Concept Multiple Choice

View Set

Preguntas cap 4 El viaje perdido

View Set