β˜‘ MCQ PRACTICE

Design and Analysis of Algorithms Unit 3

Practice objective questions for quick revision and examination preparation. Try answering each question before revealing the answer.

πŸ“š Design and Analysis of Algorithms
πŸ“– Unit 3
🎯 MCQs

Design and Analysis of Algorithms - Unit-3

1
Which of the following is/are property/properties of a dynamic programming problem?
AOptimal substructure
BOverlapping subproblems
CGreedy approach
DBoth optimal substructure and overlapping subproblems
Correct Answer Both optimal substructure and overlapping subproblems
2
If an optimal solution can be created for a problem by constructing optimal solutions for its subproblems, the problem possesses ____________ property.
AOverlapping subproblems
BOptimal substructure
CMemoization
DGreedy
Correct Answer Optimal substructure
3
If a problem can be broken into subproblems which are reused several times, the problem possesses ____________ property.
AOverlapping subproblems
BOptimal substructure
CMemoization
DGreedy
Correct Answer Overlapping subproblems
4
If a problem can be solved by combining optimal solutions to non-overlapping problems, the strategy is called _____________
ADynamic programming
BGreedy
CDivide and conquer
DRecursion
Correct Answer Divide and conquer
5
In dynamic programming, the technique of storing the previously calculated values is called ___________
ASaving value property
BStoring value property
CMemoization
DMapping
Correct Answer Memoization
6
When a top-down approach of dynamic programming is applied to a problem, it usually _____________
ADecreases both, the time complexity and the space complexity
BDecreases the time complexity and increases the space complexity
CIncreases the time complexity and decreases the space complexity
DIncreases both, the time complexity and the space complexity
Correct Answer Decreases the time complexity and increases the space complexity
7
What is the primary goal when constructing an optimal binary search tree?
ATo balance the tree perfectly
BTo minimize the average search time
CTo use all given keys
DTo maximize the tree height
Correct Answer To minimize the average search time
8
What does an optimal binary search tree guarantee?
AThe tree uses the least memory possible.
BThe shortest possible search time for each key.
CThe least number of comparisons in the worst case.
DThe minimal cost of searches, weighted by the probabilities of access.
Correct Answer The minimal cost of searches, weighted by the probabilities of access.
9
What is the recurrence relation used in the dynamic programming solution of optimal binary search trees?
Adp[i][j] = min(dp[i][k-1] + dp[k+1][j]) + w(i, j)
Bdp[i][j] = dp[i-1][j] + dp[i][j-1]
Cdp[i][j] = sum(dp[i][k-1] * dp[k+1][j]) for all k
Ddp[i][j] = 2 * dp[i-1][j] + dp[i][j-1]
Correct Answer dp[i][j] = min(dp[i][k-1] + dp[k+1][j]) + w(i, j)
10
Which of the following is necessary to build an optimal binary search tree using dynamic programming?
AFrequency of access for each key
BMaximum depth of the tree
CBinary search algorithm
DBalanced binary tree
Correct Answer Frequency of access for each key
11
How do the costs in the matrix w(i, j) in the optimal binary search tree problem generally behave?
ACosts decrease as the range increases
BCosts are constant regardless of the range
CCosts increase as the range increases
DNo relation between costs and range
Correct Answer Costs increase as the range increases
12
Which of the following statements is true about the construction of optimal binary search trees?
AAll trees of the same size have the same cost.
BOnly complete binary trees can be optimal.
CA single tree structure is optimal for any set of keys and frequencies.
DDifferent key distributions can lead to different optimal trees.
Correct Answer Different key distributions can lead to different optimal trees.
13
What does the weight function w(i, j) represent in the context of optimal binary search trees?
AThe sum of the probabilities of accessing keys between i and j
BThe difference between the highest and lowest key values
CThe number of nodes between i and j
DThe depth of the tree between i and j
Correct Answer The sum of the probabilities of accessing keys between i and j
14
Which dynamic programming solution aspect is most challenging in the context of optimal binary search trees?
AComputing the weight function w(i, j)
BChoosing the root for each subtree
CImplementing the recurrence relation
DDetermining the number of keys
Correct Answer Choosing the root for each subtree
15
What impact does increasing the access probability of a particular key have on its position in an optimal binary search tree?
AIt is more likely to be placed deeper in the tree.
BIt is more likely to be placed at the root.
CIt has no impact on the tree structure.
DIt is more likely to be placed on a leaf.
Correct Answer It is more likely to be placed at the root.
16
What is the objective of the 0/1 Knapsack Problem?
ATo maximize the total weight of the knapsack.
BTo maximize the total value of the knapsack.
CTo minimize the total weight of the knapsack.
DTo minimize the total value of the knapsack.
Correct Answer To maximize the total value of the knapsack.
17
What does the "0/1" in "0/1 Knapsack Problem" signify?
AEach item can only be used once.
BEach item can be divided into smaller parts.
CEach item is available in unlimited quantities.
DEach item has no value or weight.
Correct Answer Each item can only be used once.
18
Which approach is commonly used to solve the 0/1 Knapsack Problem?
AGreedy algorithm
BDynamic programming
CDepth-first search
DBreadth-first search
Correct Answer Dynamic programming
19
In the dynamic programming solution for the 0/1 Knapsack Problem, what does the function dp[i][w] represent?
AThe maximum value achievable with the first i items and exactly w weight.
BThe maximum weight achievable with the first i items.
CThe minimum weight achievable with the first i items and w value.
DThe minimum value achievable with exactly w weight.
Correct Answer The maximum value achievable with the first i items and exactly w weight.
20
What are the constraints of the 0/1 Knapsack Problem?
AItems' weights and values are negative.
BKnapsack's capacity is unlimited.
CEach item can only be chosen once, and the total weight must not exceed the knapsack's capacity.
DEach item can be chosen multiple times.
Correct Answer Each item can only be chosen once, and the total weight must not exceed the knapsack's capacity.
21
What is the time complexity of the dynamic programming solution for the 0/1 Knapsack Problem?
AO(n)
BO(n + W)
CO(nW)
DO(W^2)
Correct Answer O(nW)
22
In the context of the 0/1 Knapsack Problem, what is a 'feasible solution'?
AAny solution that does not exceed the knapsack's capacity.
BThe solution that involves using the least number of items.
CThe solution that maximizes the total weight in the knapsack.
DThe solution that minimizes the total value in the knapsack.
Correct Answer Any solution that does not exceed the knapsack's capacity.
23
What happens when the weight of an item is greater than the current capacity being considered in the dynamic programming table?
AThe item is included in the solution.
BThe item is excluded from the solution.
CThe solution reverts to a previous item.
DThe capacity of the knapsack is increased.
Correct Answer The item is excluded from the solution.
24
What is the primary objective of the All Pairs Shortest Path problem in graph theory?
ATo find the shortest path from one specific vertex to another.
BTo find the shortest path between every pair of vertices in a graph.
CTo detect negative weight cycles in a graph.
DTo find the longest possible path in a graph.
Correct Answer To find the shortest path between every pair of vertices in a graph.
25
Which algorithm is commonly used to solve the APSP problem?
ADijkstra’s Algorithm
BBellman-Ford Algorithm
CFloyd-Warshall Algorithm
DA* Search Algorithm
Correct Answer Floyd-Warshall Algorithm
26
What is the time complexity of the Floyd-Warshall algorithm used for solving the APSP problem?
AO(V + E)
BO(V^2)
CO(VE)
DO(V^3)
Correct Answer O(V^3)
27
In the context of the APSP, what does the matrix entry d[i][j] represent after running the Floyd-Warshall algorithm?
AThe number of edges between vertex i and j.
BThe maximum weight edge in the path from i to j.
CThe shortest path length from vertex i to vertex j.
DThe predecessor vertex to j in the shortest path from i.
Correct Answer The shortest path length from vertex i to vertex j.
28
What is the objective of the Traveling Salesperson Problem (TSP)?
ATo find a shortest possible route that visits every city and returns to the origin city.
BTo maximize the cost of traveling between cities.
CTo visit as many cities as possible.
DTo find the longest possible route that visits every city once.
Correct Answer To find a shortest possible route that visits every city and returns to the origin city.
29
In the dynamic programming solution to the TSP, what does the state dp[mask][i] represent?
AThe shortest path visiting each city in the subset mask exactly once, ending in city i.
BThe number of ways to visit cities in the subset mask.
CThe maximum distance covered by visiting cities in the subset mask.
DThe cost of traveling from the first city in the mask to city i.
Correct Answer The shortest path visiting each city in the subset mask exactly once, ending in city i.

Fill in the Blanks

30 Dynamic Programming is a technique used to solve problems by __________ them into overlapping subproblems.
Correct Answer Breaking down (or decomposing)
31 One key requirement for applying Dynamic Programming is that the problem should exhibit __________, meaning that the solution to a subproblem can be used to solve larger instances of the problem.
Correct Answer Optimal substructure
32 ____________ often involves solving each subproblem once and storing the solution to avoid redundant computations.
Correct Answer Dynamic Programming
33 Memoization is a technique in Dynamic Programming where __________ solutions to subproblems are stored and reused when needed.
Correct Answer Intermediate
34 The time complexity of a Dynamic Programming solution is typically determined by the number of __________ and the size of the __________.
Correct Answer Subproblems, table (or memoization structure)
35 Dynamic Programming is particularly useful for solving problems like __________, shortest paths, and __________ problems.
Correct Answer Knapsack, scheduling
36 Dynamic programming can significantly improve the _____________ of solving problems by avoiding redundant calculations.
Correct Answer Efficiency
← Back to All MCQs