

MCQOPTIONS
Saved Bookmarks
This section includes 8 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. |
How many times is the function recursive_get_len() called when the following code is executed? |
A. | 6 |
B. | 7 |
C. | 8 |
D. | 9View Answer |
Answer» D. 9View Answer | |
2. |
What is the time complexity of the following recursive implementation used to find the length of the string? |
A. | O(1) |
B. | O(n) |
C. | O(n2) |
D. | O(n3)View Answer |
Answer» C. O(n2) | |
3. |
Consider the following recursive implementation used to find the length of a string: Which of the following lines should be inserted to complete the above code? |
A. | 1 |
B. | len |
C. | recursive_get_len(s, len+1) |
D. | 1 + recursive_get_len(s, len+1)View Answer |
Answer» E. | |
4. |
What is the time complexity of the following code used to find the length of the string? |
A. | O(1) |
B. | O(n) |
C. | O(n2) |
D. | O(logn)View Answer |
Answer» C. O(n2) | |
5. |
Consider the following iterative implementation to find the length of the string: Which of the following lines should be inserted to complete the above code? |
A. | s[len-1] != 0 |
B. | s[len+1] != 0 |
C. | s[len] != ‘\0’ |
D. | s[len] == ‘\0’View Answer |
Answer» D. s[len] == ‘\0’View Answer | |
6. |
Which of the following can be the base case for the recursive implementation used to find the length of a string? |
A. | if(string[len] == 1) return 1 |
B. | if(string[len+1] == 1) return 1 |
C. | if(string[len] == ‘\0’) return 0 |
D. | if(string[len] == ‘\0’) return 1 |
Answer» C. if(string[len] == ‚Äö√Ñ√∂‚àö√ë‚àö‚â§\0‚Äö√Ñ√∂‚àö√ë‚àö¬•) return 0 | |
7. |
What is the time complexity of the above code used to find the length of the string? |
A. | O(1) |
B. | O(n) |
C. | O(n<sup>2</sup>) |
D. | O(logn) |
Answer» D. O(logn) | |
8. |
14 |
A. | 0 |
B. | Compile time error |
C. | Runtime error |
Answer» B. Compile time error | |