Explore topic-wise MCQs in Data Structures and Algorithms.

This section includes 5 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.

In which of the following cases is the reversal of a string not equal to the original string?

A. Palindromic strings
B. Strings of length 1
C. Empty String
D. Strings of length 2
Answer» E.
2.

How many times is the function recursive_reverse_string() called when the following code is executed?

A. 3
B. 4
C. 5
D. 6View Answer
Answer» B. 4
3.

Consider the following recursive implementation used to reverse a string: Which of the following lines should be inserted to complete the above code?

A. recursive_reverse_string(s, left+1, right+1)
B. recursive_reverse_string(s, left-1, right-1)
C. recursive_reverse_string(s, left+1, right-1)
D. recursive_reverse_string(s, left-1, right+1)View Answer
Answer» D. recursive_reverse_string(s, left-1, right+1)View Answer
4.

Consider the following iterative implementation used to reverse a string: Which of the following lines should be inserted to complete the above code?

A. i > j
B. i < len
C. j > 0
D. i < jView Answer
Answer» E.
5.

What is the time complexity of the above code used to reverse a string?

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