1.

What is the time complexity of the above code used to reverse a string?(a) O(1)(b) O(n)(c) O(n^2)(d) O(n^3)This question was addressed to me in examination.Question is taken from String Reversal using Recursion in portion Recursion of Data Structures & Algorithms II

Answer»

Correct choice is (b) O(N)

The best EXPLANATION: The time complexity of the above CODE used to reverse a STRING is O(n).



Discussion

No Comment Found

Related InterviewSolutions