Unit 4: Dynamic Programming - Practice Quiz

ECAP538 60 Questions
0 Correct 0 Wrong 60 Left
0/60

1 What is the main idea behind dynamic programming?

General method Easy
A. Sort all input values first
B. Try only random candidate solutions
C. Store and reuse subproblem solutions
D. Avoid dividing the original problem

2 Which property means that a problem contains repeatedly occurring subproblems?

General method Easy
A. Overlapping subproblems
B. Greedy-choice property
C. Stable ordering
D. Independent variables

3 Which property allows an optimal solution to be constructed from optimal solutions to smaller subproblems?

General method Easy
A. Linear ordering
B. Randomized selection
C. Optimal substructure
D. Input independence

4 What is memoization in dynamic programming?

General method Easy
A. A greedy method that chooses locally
B. A recursive method that discards results
C. A top-down method that caches results
D. A bottom-up method that sorts inputs

5 What is tabulation in dynamic programming?

General method Easy
A. Generating solutions in random order
B. Selecting the largest input each time
C. Filling a table from smaller subproblems
D. Calling recursion without storing results

6 Why does dynamic programming commonly use a table?

General method Easy
A. To reorder source code
B. To store subproblem results
C. To remove all input values
D. To generate random choices

7 Which statement describes Bellman's principle of optimality?

General method Easy
A. An optimal solution includes optimal subsolutions
B. Every local choice produces a global optimum
C. Every problem requires exhaustive enumeration
D. An optimal solution uses no stored values

8 What is optimized in the chained matrix multiplication problem?

Chained matrix multiplication Easy
A. The number of scalar multiplications
B. The number of matrices in the chain
C. The dimensions of every matrix
D. The values stored in the matrices

9 What can change when a matrix chain is parenthesized differently?

Chained matrix multiplication Easy
A. The final matrix dimensions
B. The scalar multiplication cost
C. The order of matrix entries
D. The number of input matrices

10 How many matrix multiplication operations are required to multiply a chain of matrices?

Chained matrix multiplication Easy
A.
B.
C.
D.

11 What is the cost of multiplying a matrix by a matrix using the standard method?

Chained matrix multiplication Easy
A. scalar multiplications
B. scalar multiplications
C. scalar multiplications
D. scalar multiplications

12 What is the scalar multiplication cost of multiplying a matrix by a matrix?

Chained matrix multiplication Easy
A.
B.
C.
D.

13 In matrix-chain dynamic programming, what does the base case equal?

Chained matrix multiplication Easy
A.
B.
C.
D.

14 What is the usual time complexity of the dynamic programming algorithm for matrix-chain multiplication?

Chained matrix multiplication Easy
A.
B.
C.
D.

15 What is the main objective of optimal storage on tapes?

Optimal storage on tapes Easy
A. Minimize mean retrieval time
B. Maximize individual file size
C. Maximize total tape length
D. Minimize the number of files

16 For files with equal retrieval probabilities, how should files be ordered on one tape?

Optimal storage on tapes Easy
A. In decreasing order of length
B. In increasing order of length
C. In random order of position
D. In alphabetical order of name

17 Which file should be placed first when file lengths are , , and units and access probabilities are equal?

Optimal storage on tapes Easy
A. The file of length
B. The file of length
C. Any file in the collection
D. The file of length

18 If files of lengths , , and are stored in that order, what is the retrieval time of the third file?

Optimal storage on tapes Easy
A. units
B. units
C. units
D. units

19 For files of lengths , , and stored in that order, what is the mean retrieval time?

Optimal storage on tapes Easy
A. units
B. units
C. units
D. units

20 Why are shorter files generally placed before longer files on a tape?

Optimal storage on tapes Easy
A. They reduce cumulative retrieval times
B. They remove the need for searching
C. They make every file equally large
D. They increase the physical tape length

21 Which combination of properties most directly justifies solving a problem using dynamic programming?

General method Medium
A. Sorted input and constant-time transitions
B. Unique subproblems and locally optimal choices
C. Optimal substructure and overlapping subproblems
D. Independent decisions and linear recursion

22 A memoized algorithm computes with base cases and . How many distinct states are evaluated when computing ?

General method Medium
A. states
B. states
C. states
D. states

23 For the 0/1 knapsack problem, let be the maximum value using the first items with capacity . If item has weight and value , which recurrence is correct?

General method Medium
A.
B.
C.
D.

24 What is the length of the longest common subsequence of and ?

General method Medium
A.
B.
C.
D.

25 In a DAG shortest-path dynamic program, denotes the shortest distance from source to vertex . Which recurrence applies when vertices are processed in topological order?

General method Medium
A.
B.
C.
D.

26 A two-dimensional DP recurrence uses only the previous row and already computed entries of the current row. Which optimization is generally valid?

General method Medium
A. Replace the table with one or two rows
B. Remove the recurrence base cases
C. Evaluate all states in arbitrary order
D. Replace every state with a greedy choice

27 Matrices , , and have dimensions , , and . What is the minimum number of scalar multiplications needed to compute ?

Chained matrix multiplication Medium
A.
B.
C.
D.

28 For matrices with dimension sequence , which parenthesization has minimum multiplication cost?

Chained matrix multiplication Medium
A. with cost
B. with cost
C. with cost
D. with cost

29 Let matrix have dimensions . In the matrix-chain recurrence, what is the multiplication cost when the chain is split after ?

Chained matrix multiplication Medium
A.
B.
C.
D.

30 How many complete parenthesizations are possible for a chain of five matrices?

Chained matrix multiplication Medium
A.
B.
C.
D.

31 What are the standard time and auxiliary table-space complexities of dynamic programming for a chain of matrices?

Chained matrix multiplication Medium
A. time and space
B. time and space
C. time and space
D. time and space

32 Besides the minimum-cost table, what information should be stored to reconstruct an optimal matrix-chain parenthesization?

Chained matrix multiplication Medium
A. The split index for each subchain
B. The inverse of every matrix
C. The product of all dimensions
D. The determinant of every matrix

33 Matrices , , and have dimensions , , and . How many fewer scalar multiplications does use than ?

Chained matrix multiplication Medium
A.
B.
C.
D.

34 Why are matrix-chain DP table entries usually filled in increasing order of chain length?

Chained matrix multiplication Medium
A. Only adjacent matrices may be multiplied
B. Matrix dimensions must first be sorted
C. Each entry depends on shorter subchains
D. Longer chains always have lower costs

35 Four files have lengths , , , and . Assuming equal retrieval probabilities and one tape, what order minimizes mean retrieval time?

Optimal storage on tapes Medium
A.
B.
C.
D.

36 Files of lengths , , and are stored in that order on one tape. What is their mean retrieval time if each file is equally likely to be requested?

Optimal storage on tapes Medium
A.
B.
C.
D.

37 For unequal access probabilities, file has length and probability . Which ordering rule minimizes expected retrieval time on one tape?

Optimal storage on tapes Medium
A. Nonincreasing order of
B. Nondecreasing order of
C. Nondecreasing order of
D. Nonincreasing order of

38 File has length and access probability ; file has length and probability . What is the optimal order and expected retrieval time?

Optimal storage on tapes Medium
A. with expected time
B. with expected time
C. with expected time
D. with expected time

39 Files , , and have values , , and . Which order minimizes expected retrieval time?

Optimal storage on tapes Medium
A.
B.
C.
D.

40 Files of lengths , , , and are placed on two tapes as and , with each pair stored in the shown order. Assuming equal access probabilities, what is the mean retrieval time?

Optimal storage on tapes Medium
A.
B.
C.
D.

41 A dynamic program merges multiple partial solutions into the same state. Which condition is essential for this state compression to preserve optimality?

General method Hard
A. Merged histories must have identical feasible continuations and identical incremental continuation costs.
B. Every partial solution reaching the state must use the same sequence of decisions, even when those decisions no longer affect any future transition.
C. Every state must have a unique predecessor in the dynamic-programming dependency graph.
D. Merged histories must have accumulated exactly the same cost before entering the state.

42 A top-down memoized DP is evaluated on an acyclic state graph. Exactly states are reachable from the initial state, and their transition lists contain edges in total. Each transition takes constant time. What is the tight running-time bound?

General method Hard
A.
B.
C.
D.

43 The standard 0/1 knapsack DP runs in time, where is an integer capacity encoded in binary. Which classification is most accurate?

General method Hard
A. It is polynomial in the binary input length because arithmetic is constant-time.
B. It is pseudopolynomial because may be exponential in .
C. It is strongly polynomial because the table has only entries.
D. It is exponential in for every possible encoding of the capacity.

44 A DP with states uses rolling arrays to reduce value-table memory to . The complete optimal decision sequence must later be produced without asymptotically increasing the running time. Which modification provides the general guarantee?

General method Hard
A. Store one selected predecessor for every DP state and backtrack from the optimum.
B. Store only the first and last selected decisions and interpolate the remaining ones.
C. Choose a locally optimal predecessor during backtracking without consulting discarded values.
D. Retain the final rolling array because it uniquely determines every earlier decision.

45 In a resource-constrained minimization DP, labels at the same logical state are pairs of accumulated cost and resource consumption. Under the usual monotonicity assumption that having less remaining resource cannot improve future feasibility, when can label safely be discarded?

General method Hard
A. When another label satisfies and .
B. When another label satisfies but .
C. When its cost is above the average cost of all current labels.
D. When another label satisfies and .

46 Consider the finite-horizon recurrence with known values . Which evaluation order is valid even if the underlying state-transition graph contains cycles?

General method Hard
A. Apply a topological order to the unlayered state-transition graph.
B. Evaluate layers in decreasing order of , starting from the horizon.
C. Evaluate layers in increasing order of , starting from .
D. Evaluate states by decreasing immediate transition cost within every layer.

47 Matrices have dimensions , , , and , respectively. What is the minimum number of scalar multiplications?

Chained matrix multiplication Hard
A.
B.
C.
D.

48 For a chain of matrices, how many split points are examined in total by the standard bottom-up matrix-chain DP?

Chained matrix multiplication Hard
A.
B.
C.
D.

49 A matrix-chain split table contains , , , and . Which parenthesization does it encode?

Chained matrix multiplication Hard
A.
B.
C.
D.

50 Let have dimensions . If an optimal solution for splits after , what scalar-multiplication term must be added to the two subproblem costs?

Chained matrix multiplication Hard
A.
B.
C.
D.

51 How many complete parenthesizations exist for a chain of matrices?

Chained matrix multiplication Hard
A.
B.
C.
D.

52 For dimensions , a greedy algorithm repeatedly multiplies the adjacent pair with the smallest immediate cost. What costs do the greedy and optimal solutions obtain, respectively?

Chained matrix multiplication Hard
A. and
B. and
C. and
D. and

53 Suppose each matrix in a chain may optionally be transposed before multiplication, provided the resulting products are dimensionally compatible. Why is the standard interval state generally insufficient?

Chained matrix multiplication Hard
A. Transposition makes scalar multiplication nonassociative, so no interval recurrence can be used.
B. The state must record the numerical entries of every intermediate matrix.
C. The state must also represent possible boundary dimensions or orientations of the subchain result.
D. The original recurrence remains sufficient if every multiplication cost is doubled to account for testing both orientations and all compatibility constraints.

54 All four matrices in a chain are square matrices of dimension , and ordinary multiplication is used. How many parenthesizations achieve the minimum scalar-multiplication cost?

Chained matrix multiplication Hard
A.
B.
C.
D.

55 Four files have pairs , , , and . For one sequential tape, which order minimizes expected retrieval time, and what is that expectation?

Optimal storage on tapes Hard
A. with expectation
B. with expectation
C. with expectation
D. with expectation

56 Seven equally likely files have lengths and are stored optimally across three identical tapes. Retrieval starts at the beginning of the selected tape. What is the minimum mean retrieval time?

Optimal storage on tapes Hard
A.
B.
C.
D.

57 On a single tape, adjacent files and have positive lengths and access probabilities . Under what condition is placing before no worse than placing before ?

Optimal storage on tapes Hard
A.
B.
C.
D.

58 For equally likely files and identical tapes, which construction yields an optimal arrangement under the standard sequential-retrieval model?

Optimal storage on tapes Hard
A. Sort by nonincreasing length and fill one tape completely before using the next.
B. Assign each file to the currently shortest tape while preserving the original input order.
C. Partition files so every tape has exactly the same total length, then arrange each tape from longest to shortest to reduce the number of tape switches.
D. Sort by nondecreasing length and assign files cyclically across the tapes.

59 When access probabilities differ and files may be assigned to multiple tapes, which statement is correct?

Optimal storage on tapes Hard
A. Sorting all files by and assigning them cyclically is always globally optimal.
B. Each tape must follow nondecreasing , but choosing the tape allocation remains a global problem.
C. Each tape must follow nondecreasing , regardless of how files are allocated.
D. The allocation depends only on file probabilities because lengths affect ordering but never determine which tape should hold a file.

60 A single tape contains several positive-length files. File has access probability , while every other file has positive access probability. What must hold in every optimal ordering if all lengths are positive?

Optimal storage on tapes Hard
A. appears immediately after the shortest positive-probability file.
B. may appear anywhere without changing expected retrieval time.
C. appears first because its own retrieval cost is zero.
D. Every positive-probability file appears before .