Design And Analysis Of Algorithms Set 11

On This Page

This set of Design and Analysis of Algorithms Multiple Choice Questions & Answers (MCQs) focuses on Design And Analysis Of Algorithms Set 11

Q1 | What is the time complexity of the brute force algorithm used to find the length of the longest palindromic subsequence?
  • o(1)
  • o(2n)
  • o(n)
  • o(n2)
Q2 | For every non-empty string, the length of the longest palindromic subsequence is at least one.
  • true
  • false
Q3 | Longest palindromic subsequence is an example of                              
  • greedy algorithm
  • 2d dynamic programming
  • 1d dynamic programming
  • divide and conquer
Q4 | Which of the following methods can be used to solve the edit distance problem?
  • recursion
  • dynamic programming
  • both dynamic programming and recursion
  • greedy algorithm
Q5 | The edit distance satisfies the axioms of a metric when the costs are non-negative.
  • true
  • false
Q6 | 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.
  • true
  • false
Q7 | Consider the strings “monday” and “tuesday”. What is the edit distance between the two strings?
  • 3
  • 4
  • 5
  • 6
Q8 | Consider the two strings “”(empty string) and “abcd”. What is the edit distance between the two strings?
  • 0
  • 4
  • 2
  • 3
Q9 | What is the time complexity of the Wagner–Fischer algorithm where “m” and “n” are the lengths of the two strings?
  • o(1)
  • o(n+m)
  • o(mn)
  • o(nlogm)
Q10 | Which of the following is NOT a Catalan number?
  • 1
  • 5
  • 14
  • 43
Q11 | Which of the following methods can be used to find the nth Catalan number?
  • recursion
  • binomial coefficients
  • dynamic programming
  • recursion, binomial coefficients, dynamic programming
Q12 | Which of the following implementations of Catalan numbers has the smallest time complexity?
  • dynamic programming
  • binomial coefficients
  • recursion
  • all have equal time complexity
Q13 | Which of the following methods can be used to solve the assembly line scheduling problem?
  • recursion
  • brute force
  • dynamic programming
  • all of the mentioned
Q14 | What is the time complexity of the brute force algorithm used to solve the assembly line scheduling problem?
  • o(1)
  • o(n)
  • o(n2)
  • o(2n)
Q15 | In the dynamic programming implementation of the assembly line scheduling problem, how many lookup tables are required?
  • 0
  • 1
  • 2
  • 3
Q16 | What is the time complexity of the above dynamic programming implementation of the assembly line scheduling problem?
  • o(1)
  • o(n)
  • o(n2)
  • o(n3)
Q17 | 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?
  • greedy algorithm
  • recursion
  • dynamic programming
  • both recursion and dynamic programming
Q18 | In which of the following cases the minimum no of insertions to form palindrome is maximum?
  • string of length one
  • string with all same characters
  • palindromic string
  • non palindromic string
Q19 | 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.
  • true
  • false
  • answer: b
  • 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.
Q20 | Consider the string “abbccbba”. What is the minimum number of insertions required to make the string a palindrome?
  • 0
  • 1
  • 2
  • 3
Q21 | Which of the following problems can be used to solve the minimum number of insertions to form a palindrome problem?
  • minimum number of jumps problem
  • longest common subsequence problem
  • coin change problem
  • knapsack problems
Q22 | Given a 2D matrix, find a submatrix that has the maximum sum. Which of the following methods can be used to solve this problem?
  • brute force
  • recursion
  • dynamic programming
  • brute force, recursion, dynamic programming
Q23 | In which of the following cases, the maximum sum rectangle is the 2D matrix itself?
  • when all the elements are negative
  • when all the elements are positive
  • when some elements are positive and some negative
  • when diagonal elements are positive and rest are negative
Q24 | Consider the 2×3 matrix {{1,2,3},{1,2,3}}. What is the sum of elements of the maximum sum rectangle?
  • 3
  • 6
  • 12
  • 18
Q25 | Consider the 2×2 matrix {{-1,-2},{-3,-4}}. What is the sum of elements of the maximum sum rectangle?
  • 0
  • -1
  • -7 d) -12