I came across this question while I was doing some interview prep. The choices given were: O(n) O(n^2) From what I understand the answer should have been O(n) as on every iteration a new instance of the array is being created and the previous reference is being lost. However, the book mentions the answer to be O(n^2). What could be
Tag: space-complexity
Space Complexity of an array?
I have an array of size N, and N is <=200. What would be the space complexity here. O(1) or (N) – considering the constraint N. Answer Complexity is only relevant when you try to foresee the performances of your algorithm with various input. I don’t think it has any meaning to just speak about the space-complexity of an array
Why does QuickSort use O(log(n)) extra space?
I have implemented the below quicksort algorithm. Online I’ve read that it has a space requirement of O(log(n)). Why is this the case? I’m not creating any extra data structures. Is it because my recursion will use some extra space on the stack? If this is the case, is it possible to do it with less memory by not having