Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
76 views

Design and Analysis of Algorithms Solved MCQs (Set-11)

This document contains 275 multiple choice questions about algorithms and data structures. The questions cover topics like dynamic programming, recursion, greedy algorithms, edit distance, longest common subsequence, Catalan numbers, maximum sum submatrix, and balanced partition. The questions are from design and analysis of algorithms and can be used to test knowledge of algorithms and problem solving techniques.

Uploaded by

Aamir Shaheen
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
76 views

Design and Analysis of Algorithms Solved MCQs (Set-11)

This document contains 275 multiple choice questions about algorithms and data structures. The questions cover topics like dynamic programming, recursion, greedy algorithms, edit distance, longest common subsequence, Catalan numbers, maximum sum submatrix, and balanced partition. The questions are from design and analysis of algorithms and can be used to test knowledge of algorithms and problem solving techniques.

Uploaded by

Aamir Shaheen
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 7

Design and Analysis of Algorithms MCQs

[set-11]

251. Longest palindromic subsequence is an example of


A. greedy algorithm
B. 2d dynamic programming
C. 1d dynamic programming
D. divide and conquer
Answer: B
Explanation:- longest palindromic subsequence is an example of 2d dynamic programming.

m
252. Which of the following methods can be used to solve the edit distance
o
problem?
. c
A. recursion
te
B. dynamic programming
a
M
C. both dynamic programming and recursion
q
D. greedy algorithm
Answer: C c
M
Explanation:- both dynamic programming and recursion can be used to solve the edit distance
problem.

253. The edit distance satisfies the axioms of a metric when the costs are non-
negative.
A. true
B. false
Answer: A
Explanation:- d(s,s) = 0, since each string can be transformed into itself without any change. d(s1,
s2) > 0 when s1 != s2, since the transformation would require at least one operation.

254. Suppose each edit (insert, delete, replace) has a cost of one. Then, the
maximum edit distance cost between the two strings is equal to the length of the
larger string.
A. true
B. false
Answer: A
Explanation:- consider the strings “abcd” and “efghi”. the string “efghi” can be converted to “abcd” by
deleting “i” and converting “efgh” to “abcd”. the cost of transformation is 5, which is equal to the
length of the larger string.

255. Consider the strings “monday” and “tuesday”. What is the edit distance
between the two strings?
A. 3
B. 4
C. 5
D. 6
Answer: B
Explanation:- “monday” can be converted to “tuesday” by replacing “m” with “t”, “o” with “u”, “n” with
“e” and inserting “s” at the appropriate position. so, the edit distance is 4.

256. Consider the two strings “”(empty string) and “abcd”. What is the edit
distance between the two strings?
A. 0
B. 4
C. 2
D. 3
Answer: B
Explanation:- the empty string can be transformed into “abcd” by inserting “a”, “b”, “c” and “d” at
appropriate positions. thus, the edit distance is 4.

257. What is the time complexity of the Wagner–Fischer algorithm where “m” and
“n” are the lengths of the two strings?
A. o(1)
B. o(n+m)
C. o(mn)
D. o(nlogm)
Answer: C
Explanation:- the time complexity of the wagner–fischer algorithm is o(mn).

258. Which of the following is NOT a Catalan number?


A. 1
B. 5

Download more sets at McqMate.com


C. 14
D. 43
Answer: D
Explanation:- catalan numbers are given by: (2n!)/((n+1)!n!).

259. Which of the following methods can be used to find the nth Catalan number?
A. recursion
B. binomial coefficients
C. dynamic programming
D. recursion, binomial coefficients, dynamic programming
Answer: D
Explanation:- all of the mentioned methods can be used to find the nth catalan number.

260. Which of the following implementations of Catalan numbers has the smallest
time complexity?
A. dynamic programming
B. binomial coefficients
C. recursion
D. all have equal time complexity
Answer: B
Explanation:- The time complexities are as follows: Dynamic programming: O(n2) Recursion:
Exponential Binomial coefficients: O(n).

261. Which of the following methods can be used to solve the assembly line
scheduling problem?
A. recursion
B. brute force
C. dynamic programming
D. all of the mentioned
Answer: D
Explanation:- all of the above mentioned methods can be used to solve the assembly line
scheduling problem.

262. What is the time complexity of the brute force algorithm used to solve the
assembly line scheduling problem?
A. o(1)
B. o(n)

Download more sets at McqMate.com


C. o(n2)
D. o(2n)
Answer: D
Explanation:- in the brute force algorithm, all the possible ways are calculated which are of the order
of 2n.

263. In the dynamic programming implementation of the assembly line scheduling


problem, how many lookup tables are required?
A. 0
B. 1
C. 2
D. 3
Answer: C
Explanation:- in the dynamic programming implementation of the assembly line scheduling problem,
2 lookup tables are required one for storing the minimum time and the other for storing the assembly
line number.

264. What is the time complexity of the above dynamic programming


implementation of the assembly line scheduling problem?
A. o(1)
B. o(n)
C. o(n2)
D. o(n3)
Answer: B
Explanation:- the time complexity of the above dynamic programming implementation of the
assembly line scheduling problem is o(n).

265. Given a string, you have to find the minimum number of characters to be
inserted in the string so that the string becomes a palindrome. Which of the
following methods can be used to solve the problem?
A. greedy algorithm
B. recursion
C. dynamic programming
D. both recursion and dynamic programming
Answer: D
Explanation:- dynamic programming and recursion can be used to solve the problem.

Download more sets at McqMate.com


266. In which of the following cases the minimum no of insertions to form
palindrome is maximum?
A. string of length one
B. string with all same characters
C. palindromic string
D. non palindromic string
Answer: D
Explanation:- in string of length one, string with all same characters and a palindromic string the no
of insertions is zero since the strings are already palindromes. to convert a non-palindromic string to
a palindromic string, the minimum length of string to be added is 1 which is greater than all the other
above cases. hence the minimum no of insertions to form palindrome is maximum in non-
palindromic strings.

267. In the worst case, the minimum number of insertions to be made to convert
the string into a palindrome is equal to the length of the string.
A. true
B. false
C. answer: b
D. explanation: in the worst case, the minimum number of insertions to be made to convert the
string into a palindrome is equal to length of the string minus one. for example, consider the string
“abc”. the string can be converted to “abcba” by inserting “a” and “b”. the number of insertions is
two, which is equal to length minus one.
Answer: B
Explanation:- the string can be converted to “efgfe” by inserting “f” or to “egfge” by inserting “g”.
thus, only one insertion is required.

268. Consider the string “abbccbba”. What is the minimum number of insertions
required to make the string a palindrome?
A. 0
B. 1
C. 2
D. 3
Answer: A
Explanation:- the given string is already a palindrome. so, no insertions are required.

Download more sets at McqMate.com


269. Which of the following problems can be used to solve the minimum number of
insertions to form a palindrome problem?
A. minimum number of jumps problem
B. longest common subsequence problem
C. coin change problem
D. knapsack problems
Answer: B
Explanation:- a variation of longest common subsequence can be used to solve the minimum
number of insertions to form a palindrome problem.

270. Given a 2D matrix, find a submatrix that has the maximum sum. Which of the
following methods can be used to solve this problem?
A. brute force
B. recursion
C. dynamic programming
D. brute force, recursion, dynamic programming
Answer: D
Explanation:- brute force, recursion and dynamic programming can be used to find the submatrix
that has the maximum sum.

271. In which of the following cases, the maximum sum rectangle is the 2D matrix
itself?
A. when all the elements are negative
B. when all the elements are positive
C. when some elements are positive and some negative
D. when diagonal elements are positive and rest are negative
Answer: A
Explanation:- when all the elements of a matrix are positive, the maximum sum rectangle is the 2d
matrix itself.

272. Consider the 2×3 matrix {{1,2,3},{1,2,3}}. What is the sum of elements of the
maximum sum rectangle?
A. 3
B. 6
C. 12
D. 18
Answer: C

Download more sets at McqMate.com


Explanation:- since all the elements of the 2×3 matrix are positive, the maximum sum rectangle is
the matrix itself and the sum of elements is 12.

273. Consider the 2×2 matrix {{-1,-2},{-3,-4}}. What is the sum of elements of the
maximum sum rectangle?
A. 0
B. -1
C. -7
D. -12
Answer: B
Explanation:- since all the elements of the 2×2 matrix are negative, the maximum sum rectangle is {-
1}, a 1×1 matrix containing the largest element. the sum of elements of the maximum sum rectangle
is -1.

274. The dynamic programming implementation of the maximum sum rectangle


problem uses which of the following algorithm?
A. hirschberg’s algorithm
B. needleman-wunsch algorithm
C. kadane’s algorithm
D. wagner fischer algorithm
Answer: C
Explanation:- the dynamic programming implementation of the maximum sum rectangle problem
uses kadane’s algorithm.

275. Given an array, check if the array can be divided into two subsets such that
the sum of elements of the two subsets is equal. This is the balanced partition
problem. Which of the following methods can be used to solve the balanced
partition problem?
A. dynamic programming
B. recursion
C. brute force
D. dynamic programming, recursion, brute force
Answer: D
Explanation:- all of the mentioned methods can be used to solve the balanced partition

Download more sets at McqMate.com

You might also like