MCQOPTIONS
Saved Bookmarks
This section includes 16 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. |
What is the value stored in arr[3][3] when the following code is executed? |
| A. | 2 |
| B. | 3 |
| C. | 4 |
| D. | 5View Answer |
| Answer» B. 3 | |
| 2. |
What is the space complexity of the following dynamic programming implementation to find the longest palindromic subsequence where the length of the string is n? |
| A. | O(n) |
| B. | O(1) |
| C. | O(n2) |
| D. | O(2)View Answer |
| Answer» D. O(2)View Answer | |
| 3. |
What is the time complexity of the following dynamic programming implementation to find the longest palindromic subsequence where the length of the string is n? |
| A. | O(n) |
| B. | O(1) |
| C. | O(n2) |
| D. | O(2)View Answer |
| Answer» D. O(2)View Answer | |
| 4. |
Consider the following code: Which of the following lines completes the above code? |
| A. | strrev(str2) |
| B. | str2 = str1 |
| C. | len2 = strlen(str2) |
| D. | strlen(str2)View Answer |
| Answer» B. str2 = str1 | |
| 5. |
What is the length of the longest palindromic subsequence for the string “ababcdabba”? |
| A. | 6 |
| B. | 7 |
| C. | 8 |
| D. | 9 |
| Answer» C. 8 | |
| 6. |
For which of the following, the length of the string is not equal to the length of the longest palindromic subsequence?a) A string that is a palindromeb) A string of length onec) A string that has all the same letters(e.g. aaaaa |
| A. | A string that is a palindrome |
| B. | A string of length one |
| C. | A string that has all the same letters(e.g. aaaaaa) |
| D. | Some strings of length two |
| Answer» E. | |
| 7. |
Which of the following is not a palindromic subsequence of the string “ababcdabba”? |
| A. | abcba |
| B. | abba |
| C. | abbbba |
| D. | adba |
| Answer» E. | |
| 8. |
What is the space complexity of the above dynamic programming implementation to find the longest palindromic subsequence where the length of the string is n?$ |
| A. | O(n) |
| B. | O(1) |
| C. | O(n<sup>2</sup>) |
| D. | None of the mentioned |
| Answer» B. O(1) | |
| 9. |
What_is_the_time_complexity_of_the_above_dynamic_programming_implementation_to_find_the_longest_palindromic_subsequence_where_the_length_of_the_string_is_n?$ |
| A. | O(n) |
| B. | O(1) |
| C. | O(n<sup>2</sup>) |
| D. | None of the mentioned |
| Answer» D. None of the mentioned | |
| 10. |
Longest palindromic 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. |
For every non-empty string, the length of the longest palindromic subsequence is at least one. |
| A. | True |
| B. | False |
| Answer» B. False | |
| 12. |
What is the time complexity of the brute force algorithm used to find the length of the longest palindromic subsequence? |
| A. | O(1) |
| B. | O(2<sup>n</sup>) |
| C. | O(n) |
| D. | O(n<sup>2</sup>) |
| Answer» C. O(n) | |
| 13. |
What is the length of the longest palindromic subsequence for the string “ababcdabba”?$ |
| A. | 6 |
| B. | 7 |
| C. | 8 |
| D. | 9 |
| Answer» C. 8 | |
| 14. |
For which of the following, the length of the string is equal to the length of the longest palindromic subsequence? |
| A. | A string that is a palindrome |
| B. | A string of length one |
| C. | A string that has all the same letters(e.g. aaaaaa) |
| D. | All of the mentioned |
| Answer» E. | |
| 15. |
Which of the following strings is a palindromic subsequence of the string “ababcdabba”?$ |
| A. | abcba |
| B. | abba |
| C. | abbbba |
| D. | all of the mentioned |
| Answer» E. | |
| 16. |
Which of the following methods can be used to solve the longest palindromic subsequence problem? |
| A. | Dynamic programming |
| B. | Recursion |
| C. | Brute force |
| D. | All of the mentioned |
| Answer» E. | |