All mock tests are FREE till 31 December — register to save your progress
Paper 2 CS · UNIT 07 · MOCK TEST

Mock 8 – Greedy & Dynamic Programming

Unit 7: Data Structures and Algorithms · 16 questions · about 19 minutes. Press End Mock any time to see your score and the correct answers.

All 11 topic-wise mocks in this unit
0 / 16 answered 00:00
Q1. The longest common subsequence of {1,2,3,2,4,1,2} and {2,4,3,1,2,1} is
Q2. When developing a dynamic programming algorithm, the sequence of steps followed is:
A. Construct an optimal solution from computed information.
B. Recursively define the value of an optimal solution.
C. Characterize the structure of an optimal solution.
D. Compute the value of an optimal solution, typically in a bottom-up fashion.
Choose the correct answer from the options given below:
Q3. Arrange the following steps in the correct order to solve the Knapsack problem using Dynamic Programming.
(A) Define the base case when the capacity is zero or no items are left to consider
(B) Compute the maximum value that can be obtained using items up to the i-th item and a knapsack capacity of W
(C) Identify subproblems and their dependencies based on item weights and values
(D) Initialize a table to store results of subproblems
(E) Iterate through each item and each possible capacity to fill the table
Choose the correct answer from the options given below:
Q4. Match List I with List II
List IList II
A. 8-Queens problemI. Divide and conquer
B. Closest pair of pointsII. Dynamic Programming
C. String edit problemIII. Greedy Method
D. Knapsack problemIV. Backtracking

Directions (Q91–95): For a knapsack problem, P and W are the profits and weights of a set of 7 items:
P = {9, 5, 2, 7, 6, 16, 9}
W = {2, 5, 6, 11, 1, 9, 3}

Q5. Find the optimal solution of the fractional knapsack problem when the maximum capacity is 15.

Directions (Q91–95): For a knapsack problem, P and W are the profits and weights of a set of 7 items:
P = {9, 5, 2, 7, 6, 16, 9}
W = {2, 5, 6, 11, 1, 9, 3}

Q6. What is the maximum value of the items you can carry if the maximum weight allowed is 25 (fractional knapsack)?

Directions (Q91–95): For a knapsack problem, P and W are the profits and weights of a set of 7 items:
P = {9, 5, 2, 7, 6, 16, 9}
W = {2, 5, 6, 11, 1, 9, 3}

Q7. If a new item (P = 5, W = 2) is added, giving 8 items, and the capacity is 25, then the time of fractional knapsack in this case is ______

Directions (Q91–95): For a knapsack problem, P and W are the profits and weights of a set of 7 items:
P = {9, 5, 2, 7, 6, 16, 9}
W = {2, 5, 6, 11, 1, 9, 3}

Q8. The most efficient solution to the fractional knapsack problem with maximum capacity 15 is obtained using ___

Directions (Q91–95): For a knapsack problem, P and W are the profits and weights of a set of 7 items:
P = {9, 5, 2, 7, 6, 16, 9}
W = {2, 5, 6, 11, 1, 9, 3}

Q9. Which of the following statements about the knapsack problem is correct?
Q10.

Match List I with List II

Figure

Directions (Q91–95): For a knapsack problem, the profits and weights of 7 items are P = {9, 5, 2, 7, 6, 16, 9} and W = {2, 5, 6, 11, 1, 9, 3}.

Q11.

What is the maximum value of items you can carry if maximum weight allowed is 25 with a fractional knapsack?

Directions (Q91–95): For a knapsack problem, the profits and weights of 7 items are P = {9, 5, 2, 7, 6, 16, 9} and W = {2, 5, 6, 11, 1, 9, 3}.

Q12.

If new item is added to the list, total items is 8 and capacity is 25 , then the best-case time of fractional knapsack for this case is _____

Directions (Q91–95): For a knapsack problem, the profits and weights of 7 items are P = {9, 5, 2, 7, 6, 16, 9} and W = {2, 5, 6, 11, 1, 9, 3}.

Q13.

Which of the following statements is correct for a knapsack?

Q14.

Consider the following steps : S

1 : Characterize the structure of an optimal solution S

2 : Compute the value of an optimal solution in bottom-up fashion Which of the step(s) is/are common to both dynamic programming and greedy algorithms? S

Q15.

Consider two sequences X = ⟨0, 1, 2, 1, 3, 0, 1⟩ and Y = ⟨1, 3, 2, 0, 1, 0⟩. The length of the longest common subsequence of X and Y is

Q16.

Match the following with respect to algorithm paradigms :

Figure