+1 vote
in Data Structures & Algorithms I by (110k points)
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 I

I got this question by my college director while I was bunking the class.

1 Answer

+1 vote
by (408k points)
selected by
Best 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).

Related questions

Welcome to TalkJarvis QnA, a question-answer community website for the people by the people. On TalkJarvis QnA you can ask your doubts, curiosity, questions and whatever going in your mind either related to studies or others. Experts and people from different fields will answer.