1.

What will be the auxiliary space complexity of the code to rotate an array by using the reversal algorithm (d = number of rotations)?(a) O(1)(b) O(n)(c) O(d)(d) O(n*d)The query is from Arrays Types in chapter Arrays Types of Data Structures & Algorithms II got this question by my college director while I was bunking the class.

Answer» RIGHT answer is (a) O(1)

Explanation: The reversal ALGORITHM for rotating an array does not require any AUXILIARY space. So the auxiliary space COMPLEXITY will be O(1).


Discussion

No Comment Found

Related InterviewSolutions