InterviewSolution
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 |
|
| 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 |
|
| 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 |
|
| 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 |
|
| 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 |
|
| 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 |
|
| 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 |
|
| 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 |
|
| 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 |
|
| 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 |
|
| 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 |
|
| 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} |
|
| 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 |
|
| 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 |
|
| 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 |
|
| 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) |
|
| 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 |
|
| 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 |
|
| 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 |
|
| 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 |
|
| 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 |
|
| 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 |
|
| 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 |
|
| 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 |
|
| 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 |
|
| 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 |
|
| 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 |
|
| 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 |
|
| 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) |
|
| 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) |
|
| 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 |
|
| 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) |
|
| 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 |
|
| 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 |
|
| 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 |
|
| 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 |
|
| 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 |
|
| 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 |
|
| 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) |
|
| 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) |
|
| 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 |
|
| 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 |
|
| 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 |
|