Explore topic-wise InterviewSolutions in .

This section includes InterviewSolutions, each offering curated multiple-choice questions to sharpen your knowledge and support exam preparation. Choose a topic below to get started.

1.

What is the maximum number of ways in which a boolean expression with n + 1 terms can be parenthesized, such that the output is true?(a) nth catalan number(b) n factorial(c) n cube(d) n squareI have been asked this question during an interview.I'd like to ask this question from Counting Boolean Parenthesizations in section Dynamic Programming of Data Structures & Algorithms II

Answer»

Right answer is (a) NTH catalan NUMBER

Best EXPLANATION: The number of ways will be maximum when all the possible parenthesizations result in a TRUE value. The number of possible parenthesizations is GIVEN by the nth catalan number.

2.

Which of the following gives the total number of ways of parenthesizing an expression with n + 1 terms?(a) n factorial(b) n square(c) n cube(d) nth catalan numberI had been asked this question in a job interview.My doubt is from Counting Boolean Parenthesizations in section Dynamic Programming of Data Structures & Algorithms II

Answer»

The CORRECT CHOICE is (d) nth catalan number

To explain: The nth Catalan number gives the total number of WAYS of parenthesizing an expression with n + 1 terms.

3.

Consider the expression T | F ∧ T. In how many ways can the expression be parenthesized so that the output is F (false)?(a) 0(b) 1(c) 2(d) 3This question was posed to me during an interview.My doubt stems from Counting Boolean Parenthesizations in portion Dynamic Programming of Data Structures & Algorithms II

Answer» RIGHT CHOICE is (B) 1

The EXPLANATION is: The expression can be parenthesized as (T | F) ∧ T, so that the output is F (false).
4.

Consider the expression T & F ∧ T.What is the number of ways in which the expression can be parenthesized so that the output is T (true)?(a) 0(b) 1(c) 2(d) 3This question was posed to me by my college professor while I was bunking the class.I need to ask this question from Counting Boolean Parenthesizations in division Dynamic Programming of Data Structures & Algorithms II

Answer»

Right ANSWER is (c) 2

The EXPLANATION is: The EXPRESSION can be parenthesized as (T & F) ∧ TorT & (F ∧ T), so that the OUTPUT is T.

5.

Consider the expression T & F | T. What is the number of ways in which the expression can be parenthesized so that the output is T (true)?(a) 0(b) 1(c) 2(d) 3The question was posed to me in a national level competition.The question is from Counting Boolean Parenthesizations in chapter Dynamic Programming of Data Structures & Algorithms II

Answer»

The correct choice is (c) 2

To EXPLAIN: The expression can be PARENTHESIZED as T & (F | T) and (T & F) | T so that the output is T.

6.

You are given a boolean expression which consists of operators &, | and ∧ (AND, OR and XOR) and symbols T or F (true or false). You have to find the number of ways in which the symbols can be parenthesized so that the expression evaluates to true. This is the boolean parenthesization problem. Which of the following methods can be used to solve the problem?(a) Dynamic programming(b) Recursion(c) Brute force(d) Dynamic programming, Recursion and Brute forceI have been asked this question by my school teacher while I was bunking the class.I want to ask this question from Counting Boolean Parenthesizations in chapter Dynamic Programming of Data Structures & Algorithms II

Answer»

The correct choice is (d) Dynamic programming, Recursion and Brute FORCE

Easiest EXPLANATION - Dynamic programming, Recursion and Brute force can be USED to SOLVE the Boolean parenthesization PROBLEM.

7.

There are 10 dice having 5 faces. The faces are numbered from 1 to 5. What is the number of ways in which a sum of 4 can be achieved?(a) 0(b) 2(c) 4(d) 8This question was addressed to me in an international level competition.My doubt stems from Dice Throw Problem in section Dynamic Programming of Data Structures & Algorithms II

Answer» RIGHT choice is (a) 0

Easy explanation - Since there are 10 dice and the minimum VALUE each die can take is 1, the minimum possible sum is 10. Hence, a sum of 4 cannot be achieved.
8.

There are n dice with f faces. The faces are numbered from 1 to f. What is the maximum possible sum that can be obtained when the n dice are rolled together?(a) 1(b) f*f(c) n*n(d) n*fThe question was asked in a national level competition.This key question is from Dice Throw Problem in division Dynamic Programming of Data Structures & Algorithms II

Answer» RIGHT OPTION is (d) N*f

Explanation: The sum will be maximum when all the faces SHOW a value f. The sum in this CASE will be n*f.
9.

There are n dice with f faces. The faces are numbered from 1 to f. What is the minimum possible sum that can be obtained when the n dice are rolled together?(a) 1(b) f(c) n(d) n*fI got this question in a national level competition.My enquiry is from Dice Throw Problem in division Dynamic Programming of Data Structures & Algorithms II

Answer»

The CORRECT option is (c) n

Easiest EXPLANATION - The sum will be MINIMUM when all the FACES SHOW a value 1. The sum in this case will be n.

10.

You have 2 dice each of them having 6 faces numbered from 1 to 6. What is the number of ways in which a sum of 11 can be achieved?(a) 0(b) 1(c) 2(d) 3This question was posed to me during an interview for a job.Asked question is from Dice Throw Problem in division Dynamic Programming of Data Structures & Algorithms II

Answer»

Correct choice is (c) 2

For EXPLANATION: The sum of 11 can be achieved when the dice show {6, 5} or {5, 6}.

11.

You have 3 dice each having 6 faces. What is the number of permutations that can be obtained when you roll the 3 dice together?(a) 27(b) 36(c) 216(d) 81This question was addressed to me in an online quiz.This key question is from Dice Throw Problem in division Dynamic Programming of Data Structures & Algorithms II

Answer»

The correct answer is (c) 216

Easy EXPLANATION - The TOTAL number of PERMUTATIONS that can be OBTAINED is 6 * 6 * 6 = 216.

12.

You have n dice each having f faces. What is the number of permutations that can be obtained when you roll the n dice together?(a) n*n*n…f times(b) f*f*f…n times(c) n*n*n…n times(d) f*f*f…f timesThe question was posed to me in my homework.The query is from Dice Throw Problem in chapter Dynamic Programming of Data Structures & Algorithms II

Answer»

Correct answer is (B) f*f*f…N times

The explanation is: Each die can take f values and there are n dice. So, the total NUMBER of permutations is f*f*f…n times.

13.

You are given n dice each having f faces. You have to find the number of ways in which a sum of S can be achieved. This is the dice throw problem. Which of the following methods can be used to solve the dice throw problem?(a) Brute force(b) Recursion(c) Dynamic programming(d) Brute force, Recursion and Dynamic ProgrammingThis question was posed to me in an online interview.Question is taken from Dice Throw Problem in section Dynamic Programming of Data Structures & Algorithms II

Answer»

The CORRECT OPTION is (d) Brute force, RECURSION and Dynamic Programming

The best I can explain: Brute force, Recursion and Dynamic Programming can be used to solve the DICE throw problem.

14.

What is the sum of each of the balanced partitions for the array {5, 6, 7, 10, 3, 1}?(a) 16(b) 32(c) 0(d) 64The question was asked in a national level competition.My question is based upon Balanced Partition topic in section Dynamic Programming of Data Structures & Algorithms II

Answer»

Right option is (a) 16

To EXPLAIN: The SUM of all the elements of the ARRAY is 32. So, the sum of all the elements of each partition should be 16.

15.

Consider a variation of the balanced partition problem in which we find two subsets such that |S1 – S2| is minimum. Consider the array {1, 2, 3, 4, 5}. Which of the following pairs of subsets is an optimal solution for the above problem?(a) {5, 4} & {3, 2, 1}(b) {5} & {4, 3, 2, 1}(c) {4, 2} & {5, 3, 1}(d) {5, 3} & {4, 2, 1}This question was posed to me in class test.Query is from Balanced Partition in portion Dynamic Programming of Data Structures & Algorithms II

Answer»

Right choice is (d) {5, 3} & {4, 2, 1}

The best explanation: For S1 = {5, 3} and S2 = {4, 2, 1}, SUM(S1) – sum(S2) = 1, which is the OPTIMAL SOLUTION.

16.

What is the time complexity of the brute force algorithm used to solve the balanced partition problem?(a) O(1)(b) O(n)(c) O(n^2)(d) O(2^n)This question was posed to me in a job interview.This intriguing question originated from Balanced Partition topic in section Dynamic Programming of Data Structures & Algorithms II

Answer» CORRECT ANSWER is (d) O(2^n)

For EXPLANATION: In the brute force implementation, all the POSSIBLE subsets will be formed. This takes exponential time.
17.

In which of the following cases, it is not possible to have two subsets with equal sum?(a) When the number of elements is odd(b) When the number of elements is even(c) When the sum of elements is odd(d) When the sum of elements is evenThis question was addressed to me in final exam.My question is from Balanced Partition in chapter Dynamic Programming of Data Structures & Algorithms II

Answer»

The correct choice is (C) When the sum of elements is odd

To explain: When the sum of all the elements is odd, it is not POSSIBLE to have TWO SUBSETS with EQUAL sum.

18.

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 forceI have been asked this question during a job interview.I'm obligated to ask this question of Balanced Partition topic in chapter Dynamic Programming of Data Structures & Algorithms II

Answer»

The correct CHOICE is (d) Dynamic programming, Recursion, Brute force

The best explanation: All of the mentioned METHODS can be USED to SOLVE the balanced partition PROBLEM.

19.

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 algorithmI have been asked this question at a job interview.Question is taken from Maximum Sum Rectangle in a 2D Matrix topic in portion Dynamic Programming of Data Structures & Algorithms II

Answer»

The correct option is (c) KADANE’s ALGORITHM

The explanation is: The dynamic PROGRAMMING implementation of the MAXIMUM sum rectangle problem uses Kadane’s algorithm.

20.

What is the time complexity of the brute force implementation of the maximum sum rectangle problem?(a) O(n)(b) O(n^2)(c) O(n^3)(d) O(n^4)This question was addressed to me in examination.Asked question is from Maximum Sum Rectangle in a 2D Matrix topic in division Dynamic Programming of Data Structures & Algorithms II

Answer»

Right choice is (d) O(n^4)

EASY explanation - The time complexity of the brute force IMPLEMENTATION of the maximum SUM RECTANGLE problem is O(n^4).

21.

Consider the 3×3 matrix {{2,1,-3},{6,3,4},{-2,3,0}}. What is the sum of the elements of the maximum sum rectangle?(a) 13(b) 16(c) 14(d) 19This question was addressed to me in an online quiz.This is a very interesting question from Maximum Sum Rectangle in a 2D Matrix topic in section Dynamic Programming of Data Structures & Algorithms II

Answer»

The correct choice is (C) 14

Easy explanation - The complete MATRIX REPRESENTS the maximum SUM rectangle and it’s sum is 14.

22.

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) -12I got this question during an interview.My doubt is from Maximum Sum Rectangle in a 2D Matrix topic in chapter Dynamic Programming of Data Structures & Algorithms II

Answer»

Correct option is (b) -1

The explanation is: 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.

23.

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) 18I had been asked this question by my school principal while I was bunking the class.I'm obligated to ask this question of Maximum Sum Rectangle in a 2D Matrix in portion Dynamic Programming of Data Structures & Algorithms II

Answer» RIGHT answer is (c) 12

Best 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.
24.

Consider a matrix in which all the elements are non-zero(at least one positive and at least one negative element). In this case, the sum of the elements of the maximum sum rectangle cannot be zero.(a) True(b) FalseThis question was addressed to me during an online interview.I'd like to ask this question from Maximum Sum Rectangle in a 2D Matrix in section Dynamic Programming of Data Structures & Algorithms II

Answer»

Right CHOICE is (a) True

The explanation is: If a matrix contains all non-zero ELEMENTS with at LEAST one positive and at least on negative element, then the sum of elements of the maximum sum RECTANGLE cannot be zero.

25.

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 negativeThe question was asked during an online interview.My doubt is from Maximum Sum Rectangle in a 2D Matrix topic in chapter Dynamic Programming of Data Structures & Algorithms II

Answer»

Right choice is (a) When all the elements are negative

To explain: When all the elements of a MATRIX are positive, the MAXIMUM sum RECTANGLE is the 2D matrix itself.

26.

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 programmingThis question was addressed to me by my school teacher while I was bunking the class.Question is from Maximum Sum Rectangle in a 2D Matrix topic in section Dynamic Programming of Data Structures & Algorithms II

Answer»

Right choice is (d) BRUTE force, RECURSION, Dynamic programming

The EXPLANATION is: Brute force, Recursion and Dynamic programming can be used to find the submatrix that has the maximum sum.

27.

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 programmingI had been asked this question during an online exam.Query is from Maximum Sum Rectangle in a 2D Matrix topic in chapter Dynamic Programming of Data Structures & Algorithms II

Answer»

(d) Brute force, Recursion, Dynamic PROGRAMMING

Brute force, Recursion, and Dynamic programming can be USED to FIND the submatrix that has the maximum sum.

28.

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 problemsI got this question in quiz.My question is taken from Minimum Insertions to form a Palindrome topic in section Dynamic Programming of Data Structures & Algorithms II

Answer»

The CORRECT choice is (B) Longest COMMON subsequence PROBLEM

Easiest explanation - A variation of longest common subsequence can be used to solve the minimum number of insertions to FORM a palindrome problem.

29.

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) 3The question was posed to me in a national level competition.The above asked question is from Minimum Insertions to form a Palindrome topic in portion Dynamic Programming of Data Structures & Algorithms II

Answer»

The CORRECT answer is (a) 0

The best I can explain: The GIVEN string is ALREADY a palindrome. So, no INSERTIONS are REQUIRED.

30.

Consider the string “efge”. What is the minimum number of insertions required to make the string a palindrome?(a) 0(b) 1(c) 2(d) 3This question was posed to me in an international level competition.The question is from Minimum Insertions to form a Palindrome topic in portion Dynamic Programming of Data Structures & Algorithms II

Answer»

Right option is (b) 1

Explanation: The STRING can be CONVERTED to “efgfe” by inserting “F” or to “egfge” by inserting “g”. Thus, only one insertion is REQUIRED.

31.

Consider the string “efge”. What is the minimum number of insertions required to make the string a palindrome?(a) 0(b) 1(c) 2(d) 3This question was addressed to me in an interview.Enquiry is from Minimum Insertions to form a Palindrome in chapter Dynamic Programming of Data Structures & Algorithms II

Answer»

The ANSWER is: 1

 The string can be converted to “efgfe” by INSERTING “f” or to “egfge” by inserting “g”. Thus, only ONE insertion is REQUIRED.

32.

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) FalseThis question was addressed to me during an online interview.Question is taken from Minimum Insertions to form a Palindrome topic in chapter Dynamic Programming of Data Structures & Algorithms II

Answer»

Correct choice is (b) False

The best 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.

33.

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 stringThis question was addressed to me in semester exam.My query is from Minimum Insertions to form a Palindrome in chapter Dynamic Programming of Data Structures & Algorithms II

Answer»

Right answer is (d) Non palindromic STRING

The best 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.

34.

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 programmingI have been asked this question during an interview.My enquiry is from Minimum Insertions to form a Palindrome topic in section Dynamic Programming of Data Structures & Algorithms II

Answer»

The CORRECT answer is (d) Both recursion and DYNAMIC programming

Easy explanation - Dynamic programming and recursion can be USED to SOLVE the problem.

35.

What is the space complexity of the above dynamic programming implementation of the assembly line scheduling problem?(a) O(1)(b) O(n)(c) O(n^2)(d) O(n^3)This question was posed to me by my college professor while I was bunking the class.My question comes from Assembly Line Scheduling topic in division Dynamic Programming of Data Structures & Algorithms II

Answer»

Right ANSWER is (b) O(n)

The explanation is: The SPACE COMPLEXITY of the above dynamic programming implementation of the assembly line scheduling problem is O(n).

36.

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(n^2)(d) O(n^3)This question was posed to me in an interview for internship.This interesting question is from Assembly Line Scheduling topic in portion Dynamic Programming of Data Structures & Algorithms II

Answer»

The CORRECT option is (b) O(n)

To EXPLAIN: The time complexity of the above dynamic programming IMPLEMENTATION of the assembly line scheduling problem is O(n).

37.

In the dynamic programming implementation of the assembly line scheduling problem, how many lookup tables are required?(a) 0(b) 1(c) 2(d) 3This question was posed to me during an interview.This intriguing question comes from Assembly Line Scheduling in section Dynamic Programming of Data Structures & Algorithms II

Answer»

Right option is (c) 2

Best 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.

38.

What is the time complexity of the brute force algorithm used to solve the assembly line scheduling problem?(a) O(1)(b) O(n)(c) O(n^2)(d) O(2^n)The question was asked by my college professor while I was bunking the class.Origin of the question is Assembly Line Scheduling topic in section Dynamic Programming of Data Structures & Algorithms II

Answer»

Right ANSWER is (d) O(2^n)

The BEST I can EXPLAIN: In the BRUTE force algorithm, all the possible ways are calculated which are of the order of 2^n.

39.

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 mentionedI got this question in an interview.The above asked question is from Assembly Line Scheduling topic in portion Dynamic Programming of Data Structures & Algorithms II

Answer»

Right CHOICE is (d) All of the mentioned

Easy EXPLANATION - All of the above mentioned methods can be USED to solve the assembly LINE scheduling PROBLEM.

40.

Which of the following implementations of Catalan numbers has the largest space complexity(Don’t consider the stack space)?(a) Dynamic programming(b) Binomial coefficients(c) Recursion(d) All have equal space complexitiesThis question was posed to me in an international level competition.My question comes from Catalan Number using Dynamic Programming in division Dynamic Programming of Data Structures & Algorithms II

Answer»

The correct option is (a) DYNAMIC programming

The best I can explain: The space complexities are as FOLLOWS:

Dynamic programming: O(n)

RECURSION: O(1)

Binomial coefficients: O(1).

41.

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 complexityThis question was posed to me in unit test.My question is from Catalan Number using Dynamic Programming in section Dynamic Programming of Data Structures & Algorithms II

Answer»

Correct option is (B) Binomial coefficients

For explanation: The time complexities are as follows:

DYNAMIC PROGRAMMING: O(n^2)

RECURSION: Exponential

Binomial coefficients: O(n).

42.

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 programmingThe question was posed to me by my school principal while I was bunking the class.This key question is from Catalan Number using Dynamic Programming topic in chapter Dynamic Programming of Data Structures & Algorithms II

Answer»

The correct option is (d) RECURSION, Binomial Coefficients, DYNAMIC programming

The BEST I can explain: All of the mentioned methods can be used to FIND the NTH Catalan number.

43.

Which of the following is not an application of Catalan Numbers?(a) Counting the number of Dyck words(b) Counting the number of expressions containing n pairs of parenthesis(c) Counting the number of ways in which a convex polygon can be cut into triangles by connecting vertices with straight lines(d) Creation of head and tail for a given number of tossesThe question was posed to me during a job interview.I would like to ask this question from Catalan Number using Dynamic Programming topic in chapter Dynamic Programming of Data Structures & Algorithms II

Answer»

Correct OPTION is (d) CREATION of head and tail for a given number of tosses

The best explanation: Counting the number of Dyck words, Counting the number of expressions containing n pairs of parenthesis, Counting the number of ways in which a convex POLYGON can be cut into triangles by connecting vertices with straight lines are the APPLICATIONS of Catalan numbers where as creation of head and tails for a given number of tosses is an application of Pascal’s TRIANGLE.

44.

Which of the following numbers is the 6th Catalan number?(a) 14(b) 429(c) 132(d) 42The question was asked in final exam.Asked question is from Catalan Number using Dynamic Programming in chapter Dynamic Programming of Data Structures & Algorithms II

Answer» CORRECT choice is (d) 42

The BEST I can explain: Catalan numbers are given by: (2n!)/((n+1)!n!).

First Catalan number is given by n = 0.

So the 6th Catalan number will be given by n = 5, which is 42.
45.

Which of the following is NOT a Catalan number?(a) 1(b) 5(c) 14(d) 43The question was asked in unit test.I'd like to ask this question from Catalan Number using Dynamic Programming in portion Dynamic Programming of Data Structures & Algorithms II

Answer»

Right choice is (d) 43

The explanation is: Catalan NUMBERS are given by: (2N!)/((n+1)!n!).

For n = 0, we get C0 = 1.

For n = 3, we get C3 = 5.

For n = 4, we get C4 = 14.

For n = 5, we get C3 = 42.

46.

What is the space complexity of the above implementation of 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)The question was asked by my school principal while I was bunking the class.My question comes from Wagner-Fischer Algorithm topic in section Dynamic Programming of Data Structures & Algorithms II

Answer»

Correct ANSWER is (C) O(mn)

Best EXPLANATION: The space complexity of the above Wagner–Fischer algorithm is O(mn).

47.

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)The question was asked in quiz.My doubt stems from Wagner-Fischer Algorithm in chapter Dynamic Programming of Data Structures & Algorithms II

Answer»

The CORRECT ANSWER is (C) O(mn)

The BEST I can explain: The time complexity of the Wagner–Fischer algorithm is O(mn).

48.

For which of the following pairs of strings is the edit distance maximum?(a) sunday & monday(b) monday & tuesday(c) tuesday & wednesday(d) wednesday & thursdayThis question was posed to me during an interview.This interesting question is from Wagner-Fischer Algorithm topic in section Dynamic Programming of Data Structures & Algorithms II

Answer»

Right choice is (d) WEDNESDAY & thursday

The EXPLANATION is: The edit distances are 2, 4, 4 and 5 respectively. Hence, the MAXIMUM edit distance is between the strings wednesday and thursday.

49.

What is the edit distance between the strings “abcd” and “acbd” when the allowed operations are insertion, deletion and substitution?(a) 1(b) 2(c) 3(d) 4This question was posed to me by my college director while I was bunking the class.Origin of the question is Wagner-Fischer Algorithm in section Dynamic Programming of Data Structures & Algorithms II

Answer»

Right choice is (b) 2

Easy explanation - The string “ABCD” can be changed to “acbd” by substituting “b” with “C” and “c” with “b”. THUS, the EDIT distance is 2.

50.

Wagner–Fischer algorithm is used to find ____________(a) Longest common subsequence(b) Longest increasing subsequence(c) Edit distance between two strings(d) Longest decreasing subsequenceI have been asked this question in an interview for internship.This interesting question is from Wagner-Fischer Algorithm in division Dynamic Programming of Data Structures & Algorithms II

Answer»

Right choice is (c) Edit distance between TWO STRINGS

The explanation is: Wagner–Fischer ALGORITHM is USED to find the edit distance between two strings.