[Solved] What will be the auxiliary space complexity of the code to rotate an array by using the reversal algorithm (d = number of rotations)?

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)

Answer: a
Explanation: The reversal algorithm for rotating an array does not require any auxiliary space. So the auxiliary space complexity will be O(1).

Comments