Arrays.sort() method uses quicksort for arrays of
primitives and merge sort for arrays of objects.
· Quicksort is faster than merge sort
and costs less memory.
· Quicksort is not stable,
i.e. equal entries can change their relative position during the sort, this
means that if you sort an already sorted array, it may not stay unchanged.
· Merge sort requires making a clone
of the array.
· Quicksort is O(nlogn) on average and
O(n2) in the worst case. At the same time, other sorting algorithms are studied
which are O(nlogn) in the worst case (like mergesort and heapsort).
No comments:
Post a Comment