Explore topic-wise MCQs in Data Structures and Algorithms.

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

1.

Which of the following is the longest common subsequence between the strings “hbcfgmnapq” and “cbhgrsfnmq” ?

A. hgmq
B. cfnq
C. bfmq
D. fgmna
Answer» E.
2.

What is the space complexity of the following dynamic programming implementation of the longest common subsequence problem where length of one string is “m” and the length of the other string is “n”?

A. O(n)
B. O(m)
C. O(m + n)
D. O(mn)View Answer
Answer» E.
3.

What is the time complexity of the following dynamic programming implementation of the longest common subsequence problem where length of one string is “m” and the length of the other string is “n”?

A. O(n)
B. O(m)
C. O(m + n)
D. O(mn)View Answer
Answer» E.
4.

Consider the following dynamic programming implementation of the longest common subsequence problem: Which of the following lines completes the above code?

A. arr[i][j] = 1 + arr[i][j].
B. arr[i][j] = 1 + arr[i – 1][j – 1].
C. arr[i][j] = arr[i – 1][j – 1].
D. arr[i][j] = arr[i][j].View Answer
Answer» C. arr[i][j] = arr[i – 1][j – 1].
5.

Consider the strings “PQRSTPQRS” and “PRATPBRQRPS”. What is the length of the longest common subsequence?

A. 9
B. 8
C. 7
D. 6
Answer» D. 6
6.

WHAT_IS_THE_SPACE_COMPLEXITY_OF_THE_ABOVE_DYNAMIC_PROGRAMMING_IMPLEMENTATION_OF_THE_LONGEST_COMMON_SUBSEQUENCE_PROBLEM_WHERE_LENGTH_OF_ONE_STRING_IS_‚ÄÖ√Ñ√∂‚ÀÖ√Ë‚ÀÖ‚À´M‚ÄÖ√Ñ√∂‚ÀÖ√Ë‚ÀÖŒÄ_AND_THE_LENGTH_OF_THE_OTHER_STRING_IS_‚ÄÖ√Ñ√∂‚ÀÖ√Ë‚ÀÖ‚À´N‚ÄÖ√Ñ√∂‚ÀÖ√Ë‚ÀÖŒÄ??$#

A. O(n)
B. O(m)
C. O(m + n)
D. O(mn)
Answer» C. O(m + n)
7.

Which of the following is the longest common subsequence between the strings “hbcfgmnapq” and “cbhgrsfnmq” ?$

A. hgmq
B. cfnq
C. bfmq
D. all of the mentioned
Answer» E.
8.

What is the time complexity of the above dynamic programming implementation of the longest common subsequence problem where length of one string is “m” and the length of the other string is “n”?#

A. O(n)
B. O(m)
C. O(m + n)
D. O(mn)
Answer» E.
9.

What is the time complexity of the brute force algorithm used to find the longest common subsequence?

A. O(n)
B. O(n<sup>2</sup>)
C. O(n<sup>3</sup>)
D. O(2<sup>n</sup>)
Answer» E.
10.

Longest common subsequence is an example of ____________

A. Greedy algorithm
B. 2D dynamic programming
C. 1D dynamic programming
D. Divide and conquer
Answer» C. 1D dynamic programming
11.

Which of the following problems can be solved using the longest subsequence problem?

A. Longest increasing subsequence
B. Longest palindromic subsequence
C. Longest bitonic subsequence
D. None of the mentioned
Answer» C. Longest bitonic subsequence
12.

Consider the strings “PQRSTPQRS” and “PRATPBRQRPS”. What is the length of the longest common subsequence?$

A. 9
B. 8
C. 7
D. 6
Answer» D. 6
13.

Which of the following methods can be used to solve the longest common subsequence problem?

A. Recursion
B. Dynamic programming
C. Both recursion and dynamic programming
D. None of the mentioned
Answer» D. None of the mentioned