11. Sort
Sorting
Java use modified mergesort by java.util.Collections.sort to sort object
Guarantees O(nlogn) performance and O(n) extra space
Stable in all kinds of input
Java use quicksort in java.util.Arrays.sort
Avarage less than O(nlogn), worst case O(n^2)
Average O(logn) extra space, worst case O(n/2) extra space
Stable only in primitive type
Quicksort
Last updated
Was this helpful?