B.A subsequence whose elements are in decreasing order
C.A subsequence whose elements are in increasing order
D.A subarray containing only positive elements
Correct Answer: A subsequence whose elements are in increasing order
Explanation:
An increasing subsequence preserves the original element order and has each selected element greater than the previous one.
Incorrect! Try again.
2What is the length of the LIS in the sequence ?
Longest Increasing Subsequence (LIS)
Easy
A.
B.
C.
D.
Correct Answer:
Explanation:
The subsequence is increasing and has length .
Incorrect! Try again.
3Which of the following is an increasing subsequence of ?
Longest increasing subsequence
Easy
A.
B.
C.
D.
Correct Answer:
Explanation:
preserves the original order, and every element is greater than the preceding element.
Incorrect! Try again.
4What does LCS stand for?
Longest Common Subsequence (LCS)
Easy
A.Longest Consecutive Subarray
B.Longest Common Subsequence
C.Largest Continuous Sequence
D.Least Common Subarray
Correct Answer: Longest Common Subsequence
Explanation:
LCS stands for Longest Common Subsequence.
Incorrect! Try again.
5Which sequence is a common subsequence of and ?
Longest common subsequence
Easy
A.
B.
C.
D.
Correct Answer:
Explanation:
appears in both strings in the same relative order.
Incorrect! Try again.
6What is the length of the LCS of and ?
Longest Common Subsequence (LCS)
Easy
A.
B.
C.
D.
Correct Answer:
Explanation:
The string is a subsequence of both strings, so the LCS length is .
Incorrect! Try again.
7What does the binomial coefficient count?
Binomial coefficient
Easy
A.Ways to order distinct objects
B.Ways to add objects to
C.Ways to choose objects from
D.Ways to divide by
Correct Answer: Ways to choose objects from
Explanation:
counts the selections of objects from objects when order does not matter.
Incorrect! Try again.
8What is the value of ?
Binomial coefficient
Easy
A.
B.
C.
D.
Correct Answer:
Explanation:
.
Incorrect! Try again.
9What is the usual objective of the Box Stacking problem?
Box Stacking
Easy
A.Minimize the number of available boxes
B.Minimize the weight of the stack
C.Maximize the height of a valid stack
D.Maximize the width of every box
Correct Answer: Maximize the height of a valid stack
Explanation:
The goal is to arrange boxes under the stacking constraints so that the total stack height is as large as possible.
Incorrect! Try again.
10When can one box normally be placed on another in the Box Stacking problem?
Box Stacking
Easy
A.Its height equals the lower box's height
B.Its volume equals the lower box's volume
C.Its base is strictly smaller in both dimensions
D.Its base is strictly larger in both dimensions
Correct Answer: Its base is strictly smaller in both dimensions
Explanation:
A box can normally be placed above another when both dimensions of its base are smaller than those of the lower box.
Incorrect! Try again.
11What does "duplicate items forbidden" mean in the integer knapsack problem?
Integer Knapsack Problem (Duplicate Items Forbidden)
Easy
A.Each item may be selected at most once
B.Only items with equal weights are selected
C.Each item must be selected exactly twice
D.Only items with distinct values are selected
Correct Answer: Each item may be selected at most once
Explanation:
This is the knapsack rule: every item is either selected once or not selected.
Incorrect! Try again.
12What is the main objective of the knapsack problem?
Integer Knapsack Problem (Duplicate Items Forbidden)
Easy
A.Minimize capacity without selecting items
B.Minimize value while filling the knapsack
C.Maximize weight without considering value
D.Maximize value without exceeding capacity
Correct Answer: Maximize value without exceeding capacity
Explanation:
The selected items should have the greatest total value while their total weight remains within the knapsack capacity.
Incorrect! Try again.
13Which operation is commonly allowed in the standard Edit Distance problem?
Edit Distance
Easy
A.Insert a character
B.Reverse the whole string
C.Sort all characters
D.Duplicate the whole string
Correct Answer: Insert a character
Explanation:
Standard Edit Distance allows character insertion, deletion, and replacement.
Incorrect! Try again.
14What is the edit distance between and ?
Edit Distance
Easy
A.
B.
C.
D.
Correct Answer:
Explanation:
Replacing with changes into in one operation.
Incorrect! Try again.
15What does the Matrix Chain Multiplication problem seek to minimize?
Matrix Chain Multiplication
Easy
A.The number of scalar multiplications
B.The number of rows in each matrix
C.The number of matrices in the chain
D.The number of stored matrix elements
Correct Answer: The number of scalar multiplications
Explanation:
The problem finds a parenthesization that minimizes the total number of scalar multiplication operations.
Incorrect! Try again.
16Multiplying a matrix of size by a matrix of size requires how many scalar multiplications?
Matrix Chain Multiplication
Easy
A.
B.
C.
D.
Correct Answer:
Explanation:
The multiplication requires scalar multiplications.
Incorrect! Try again.
17What is the goal of a Balanced Partition problem?
Balanced Partition
Easy
A.Remove every element with an odd value
B.Place all elements into one large subset
C.Split elements into subsets with close sums
D.Arrange elements in strictly increasing order
Correct Answer: Split elements into subsets with close sums
Explanation:
Balanced Partition divides the elements into two subsets while minimizing the difference between their sums.
Incorrect! Try again.
18Which pair of subsets forms a perfectly balanced partition of ?
Balanced Partition Problem
Easy
A. and
B. and
C. and
D. and
Correct Answer: and
Explanation:
Both subsets have sum , so the difference between their sums is .
Incorrect! Try again.
19If two partition subsets have sums and , what is the difference between their sums?
Balanced Partition
Easy
A.
B.
C.
D.
Correct Answer:
Explanation:
The absolute difference is .
Incorrect! Try again.
20When is a partition considered perfectly balanced?
Balanced Partition Problem
Easy
A.The two subsets contain only even values
B.The two subsets have equal total sums
C.The two subsets contain identical elements
D.The two subsets have increasing elements
Correct Answer: The two subsets have equal total sums
Explanation:
A perfectly balanced partition has a sum difference of , meaning both subset sums are equal.
Incorrect! Try again.
21What is the length of the longest strictly increasing subsequence in the sequence ?
Longest increasing subsequence
Medium
A.
B.
C.
D.
Correct Answer:
Explanation:
Examples of longest increasing subsequences are and , each having length .
Incorrect! Try again.
22In the LIS algorithm, what does the array of tail values represent?
Longest Increasing Subsequence (LIS)
Medium
A.The number of subsequences ending at each index
B.The largest tail for each subsequence length
C.The smallest tail for each subsequence length
D.The predecessor index of every array element
Correct Answer: The smallest tail for each subsequence length
Explanation:
For each possible length, the algorithm stores the smallest ending value found so far. Smaller tails provide more opportunities for extension.
Incorrect! Try again.
23For a strictly increasing subsequence, what is the LIS length of ?
Longest Increasing Subsequence (LIS)
Medium
A.
B.
C.
D.
Correct Answer:
Explanation:
Equal values cannot follow one another in a strictly increasing subsequence, so only one element can be selected.
Incorrect! Try again.
24What is the length of the LCS of the strings AGGTAB and GXTXAYB?
Longest common subsequence
Medium
A.
B.
C.
D.
Correct Answer:
Explanation:
The sequence GTAB occurs in both strings in the same relative order, so the LCS length is .
Incorrect! Try again.
25If , which recurrence correctly computes the LCS table entry ?
Longest Common Subsequence (LCS)
Medium
A.
B.
C.
D.
Correct Answer:
Explanation:
When the characters differ, the best LCS excludes one of them and takes the larger result from the two corresponding subproblems.
Incorrect! Try again.
26Which sequence is an LCS of ABCDGH and AEDFHR?
Longest Common Subsequence (LCS)
Medium
A.ADH
B.DFR
C.BDH
D.AEH
Correct Answer: ADH
Explanation:
ADH appears in both strings in order and has length , which is the maximum possible for these strings.
Incorrect! Try again.
27Using the recurrence , what is ?
Binomial coefficient
Medium
A.
B.
C.
D.
Correct Answer:
Explanation:
. The same value is obtained by filling Pascal's recurrence table.
Incorrect! Try again.
28When computing binomial coefficients with a one-dimensional DP array, why should be processed from right to left for each new value of ?
Binomial coefficient
Medium
A.To eliminate the base case at
B.To reduce multiplication overflow
C.To sort coefficients in decreasing order
D.To preserve values from the previous row
Correct Answer: To preserve values from the previous row
Explanation:
A right-to-left update prevents a newly written value from being reused during the same row calculation.
Incorrect! Try again.
29A box orientation has base dimensions . Which box orientation can be placed directly on top of it under the strict box-stacking rule?
Box Stacking
Medium
A.Base
B.Base
C.Base
D.Base
Correct Answer: Base
Explanation:
Both base dimensions of the upper box must be strictly smaller than the corresponding dimensions and .
Incorrect! Try again.
30After generating all valid rotations in the standard box-stacking DP, why are orientations commonly sorted by decreasing base area?
Box Stacking
Medium
A.To guarantee equal base dimensions are stacked together
B.To minimize the number of rotations generated
C.To process larger supporting bases before smaller bases
D.To ensure every box uses its shortest side as height
Correct Answer: To process larger supporting bases before smaller bases
Explanation:
The ordering allows the algorithm to build maximum-height stacks by considering potential supporting orientations before orientations placed above them.
Incorrect! Try again.
31A knapsack has capacity . Items have (weight, value) pairs , , , and . What is the maximum obtainable value?
Integer Knapsack Problem (Duplicate Items Forbidden)
Medium
A.
B.
C.
D.
Correct Answer:
Explanation:
Taking the item of weight gives value . The only useful combination, weights , gives the smaller value .
Incorrect! Try again.
32In a one-dimensional knapsack DP, in which order should capacities be updated for each item?
Integer Knapsack Problem (Duplicate Items Forbidden)
Medium
A.From zero up to item value
B.From item weight up to capacity
C.From capacity down to item weight
D.From item value down to zero
Correct Answer: From capacity down to item weight
Explanation:
Descending updates ensure that each item contributes at most once. Ascending updates could reuse the same item during its own iteration.
Incorrect! Try again.
33With unit-cost insertion, deletion, and substitution, what is the edit distance between kitten and sitting?
Edit Distance
Medium
A.
B.
C.
D.
Correct Answer:
Explanation:
One optimal transformation substitutes k with s, substitutes e with i, and inserts g, for a total cost of .
Incorrect! Try again.
34Suppose insertion and deletion each cost , while substitution costs . What is the minimum cost to transform cat into cut?
Edit Distance
Medium
A.
B.
C.
D.
Correct Answer:
Explanation:
Replacing a with u costs . Deleting a and inserting u also costs , so the minimum cost is .
Incorrect! Try again.
35Matrices , , and have dimensions , , and . What is the minimum number of scalar multiplications?
Matrix Chain Multiplication
Medium
A.
B.
C.
D.
Correct Answer:
Explanation:
Using costs , which is less than the alternative cost.
Incorrect! Try again.
36For five matrices, how many nontrivial contiguous matrix-chain subproblems are stored in the upper triangular portion of the standard DP table?
Matrix Chain Multiplication
Medium
A.
B.
C.
D.
Correct Answer:
Explanation:
Intervals containing at least two matrices number . For , this is .
Incorrect! Try again.
37If matrix has dimensions , what multiplication cost is added when splitting the chain after ?
Matrix Chain Multiplication
Medium
A.
B.
C.
D.
Correct Answer:
Explanation:
The two resulting products have dimensions and , so combining them costs .
Incorrect! Try again.
38What is the minimum difference between subset sums when partitioning into two subsets?
Balanced Partition
Medium
A.
B.
C.
D.
Correct Answer:
Explanation:
The total is . Subsets with sums and , such as and , produce the minimum difference .
Incorrect! Try again.
39For positive integers with total sum , which subset sum should a balanced-partition DP try to maximize?
Balanced Partition Problem
Medium
A.A reachable sum equal to the largest item
B.A reachable sum at most
C.A reachable sum at least
D.A reachable sum at most
Correct Answer: A reachable sum at most
Explanation:
Choosing the largest reachable sum minimizes the difference between the two subsets.
Incorrect! Try again.
40What is the minimum partition difference for the array ?
Balanced Partition Problem
Medium
A.
B.
C.
D.
Correct Answer:
Explanation:
The total sum is , so an equal partition is impossible. Reachable subset sums and give the minimum difference .
Incorrect! Try again.
41For the sequence , how many distinct index-based longest strictly increasing subsequences exist?
Longest increasing subsequence
Hard
A.
B.
C.
D.
Correct Answer:
Explanation:
The LIS length is . The four LISs are , , , and .
Incorrect! Try again.
42After processing with the tails-array LIS algorithm, the tails array is . Which interpretation is correct?
Longest Increasing Subsequence (LIS)
Hard
A.It is an LIS of the input
B.It stores minimum tails by length
C.It stores maximum tails by length
D.It stores the earliest LIS found
Correct Answer: It stores minimum tails by length
Explanation:
Each position stores the smallest known tail for an increasing subsequence of that length. Here is not an input subsequence because occurs before .
Incorrect! Try again.
43An LIS implementation replaces the first tails-array element that is greater than or equal to the current value. What change is required to compute the longest nondecreasing subsequence instead?
Longest increasing subsequence
Hard
A.Replace the first element smaller than the value
B.Replace the last element equal to the value
C.Replace the last element greater than the value
D.Replace the first element greater than the value
Correct Answer: Replace the first element greater than the value
Explanation:
Strict LIS uses a lower-bound search for the first value . A nondecreasing subsequence uses an upper-bound search for the first value .
Incorrect! Try again.
44How many distinct longest common subsequence strings do and have?
Longest common subsequence
Hard
A.
B.
C.
D.
Correct Answer:
Explanation:
The LCS length is , and the distinct LCS strings are , , and .
Incorrect! Try again.
45Suppose only insertions and deletions are allowed when transforming a string of length into a string of length . If their LCS length is , what is the minimum number of operations?
Longest Common Subsequence (LCS)
Hard
A.
B.
C.
D.
Correct Answer:
Explanation:
Delete the characters of outside an LCS, then insert the missing characters of . The total is .
Incorrect! Try again.
46A standard LCS reconstruction encounters a state where moving up and moving left preserve the same optimal length. What is necessary to guarantee the lexicographically smallest LCS?
Longest common subsequence
Hard
A.Choose the path with fewer diagonal moves
B.Always move up at every tie
C.Always move left at every tie
D.Compare optimal suffix results at ties
Correct Answer: Compare optimal suffix results at ties
Explanation:
Equal-length DP choices can produce different LCS strings. Lexicographic minimality requires comparing or otherwise ranking the optimal strings obtainable from tied states.
Incorrect! Try again.
47Using Lucas's theorem, what is ?
Binomial coefficient
Hard
A.
B.
C.
D.
Correct Answer:
Explanation:
In base , and . Thus .
Incorrect! Try again.
48A one-dimensional DP computes using . In what order must be processed for each new row?
Binomial coefficient
Hard
A.Ascending from to
B.Ascending from to
C.Descending from to
D.Descending from to
Correct Answer: Descending from to
Explanation:
Descending order ensures that still belongs to the previous Pascal row. Ascending order would reuse values already updated in the current row.
Incorrect! Try again.
49Which expression gives the correct asymptotic growth of the central binomial coefficient ?
Binomial coefficient
Hard
A.
B.
C.
D.
Correct Answer:
Explanation:
Stirling's approximation gives , so its asymptotic order is .
Incorrect! Try again.
50For each box orientation, normalize its base as . Under strict two-dimensional fitting, which graph formulation correctly represents the unrestricted box-stacking DP?
Box Stacking
Hard
A.A DAG edge between bases having equal area
B.An undirected edge between any comparable bases
C.A DAG edge from a taller box to a shorter box
D.A DAG edge from a larger base to a smaller base
Correct Answer: A DAG edge from a larger base to a smaller base
Explanation:
Create an edge from orientation to when both normalized base dimensions of are strictly larger. Maximum stack height is then a longest weighted path in this DAG.
Incorrect! Try again.
51Why is ordinary longest-path DP over all box rotations insufficient when each physical box may be used at most once?
Box Stacking
Hard
A.A path may use two rotations of one box
B.Rotations can produce negative box heights
C.Strict fitting makes the graph cyclic
D.Base normalization changes the box volume
Correct Answer: A path may use two rotations of one box
Explanation:
Different rotation vertices may refer to the same physical box. A valid path in the rotation graph can therefore reuse that box, so the state must also track used box identities.
Incorrect! Try again.
52In a one-dimensional knapsack DP, why must capacities be processed from down to the current item's weight?
Integer Knapsack Problem (Duplicate Items Forbidden)
Hard
A.To exclude states below the capacity
B.To prevent reusing the current item
C.To maintain values in sorted order
D.To prefer items with larger weights
Correct Answer: To prevent reusing the current item
Explanation:
Descending iteration reads every source state from before the current item was added. Ascending iteration can read a newly updated state and use the same item multiple times.
Incorrect! Try again.
53A knapsack has capacity and items equal to , , , and . What is the maximum value?
Integer Knapsack Problem (Duplicate Items Forbidden)
Hard
A.
B.
C.
D.
Correct Answer:
Explanation:
Selecting the items of weights and exactly fills the capacity and gives value . Every other feasible subset has a smaller value.
Incorrect! Try again.
54Insertion and deletion each cost , while replacement costs . What is the minimum weighted edit distance from to ?
Edit Distance
Hard
A.
B.
C.
D.
Correct Answer:
Explanation:
Insert at cost and replace by at cost , for a total of . Deleting and reinserting the final character would cost instead of .
Incorrect! Try again.
55A rolling-row edit-distance implementation uses memory. What additional requirement prevents direct reconstruction of an optimal edit script from only the final rolling rows?
Edit Distance
Hard
A.Sorted characters in both input strings
B.Predecessor decisions for discarded states
C.Equal lengths for both input strings
D.Symmetric insertion and deletion costs
Correct Answer: Predecessor decisions for discarded states
Explanation:
Rolling rows preserve the optimal distance but discard most DP states and their choices. Reconstruction requires stored predecessors, recomputation, or a divide-and-conquer method.
Incorrect! Try again.
56Matrices have dimensions , , , and . What is the minimum number of scalar multiplications?
Matrix Chain Multiplication
Hard
A.
B.
C.
D.
Correct Answer:
Explanation:
The optimal parenthesization is . Its cost is .
Incorrect! Try again.
57For a chain of compatible matrices, how many complete parenthesizations must a brute-force method potentially consider before using cost-based pruning?
Matrix Chain Multiplication
Hard
A.
B.
C.
D.
Correct Answer:
Explanation:
A chain of matrices has the Catalan number of parenthesizations. For , this is .
Incorrect! Try again.
58For nonnegative integers with total sum , which subset-sum objective directly yields the minimum possible difference between two partition sums?
Balanced Partition
Hard
A.Minimize reachable
B.Maximize reachable
C.Maximize reachable
D.Minimize reachable
Correct Answer: Maximize reachable
Explanation:
If one subset has sum , the difference is . Maximizing such a reachable therefore minimizes the difference.
Incorrect! Try again.
59The usual bitset solution for balanced partition indexes reachable sums from to . What modification is required if negative input values are allowed?
Balanced Partition Problem
Hard
A.Discard all values smaller than zero
B.Replace each value by its absolute value
C.Offset indices across the full sum range
D.Sort values by their absolute magnitudes
Correct Answer: Offset indices across the full sum range
Explanation:
Reachable sums may range from the sum of negative values to the sum of positive values. An offset maps this full interval to nonnegative DP indices.
Incorrect! Try again.
60For the multiset , what is the minimum absolute difference between the sums of two partitions?
Balanced Partition Problem
Hard
A.
B.
C.
D.
Correct Answer:
Explanation:
The total is , and the subset has sum . Its complement also has sum , giving difference .
Incorrect! Try again.
Did this save you a night before the exam?
LPU Notes is free, and it stays free. Ads cover part of the server bill.
The rest comes out of a student's own pocket: the domain, the storage,
and keeping the site up through the weeks everyone needs it at once.
The payment button didn't load. An ad blocker or a filtered network is the usual reason.
to try again.
Nothing here is ever locked, and nothing unlocks. Chip in only if it was worth it.
What it pays for →