Grokking LinkedIn Coding Interview
Ask Author
Back to course home

0% completed

Vote For New Content
How is the space complexity O(N) for the sort?

Kennedy

Jun 3, 2023

Isn't sorting done in place? If so, shouldn't the space complexity because be constant if we are ignore the output array?

0

0

Comments
Comments
Shubham Vora
Shubham Voraa year ago

In Java, Arrays.sort is optimized and uses different algorithms based on the type of array:

  • For Primitive Types (e.g., int[]): Java’s Arrays.sort for primitive types generally uses a variant of Dual-Pivot QuickSort. Its average-case space complexity i...

On this page