Does anyone know the running time in big O notation for the arrays.sort java method? I need this for my science fair project.
From official docs
I’ve observed that there are primarily two approaches. So, it depends on what you are sorting and what overloaded method from
sort family of methods you are calling.
Docs mention that for primitive types such as
static void sort(long)):
The sorting algorithm is a tuned quicksort, adapted from Jon L. Bentley and M. Douglas McIlroy’s “Engineering a Sort Function”, Software-Practice and Experience, Vol. 23(11) P. 1249-1265 (November 1993). This algorithm offers n*log(n) performance on many data sets that cause other quicksorts to degrade to quadratic performance.
For Object types: (Ex:
void sort(Object list))
Guaranteed O(nlogn) performance
The sorting algorithm is a modified mergesort (in which the merge is omitted if the highest element in the low sublist is less than the lowest element in the high sublist). This algorithm offers guaranteed n*log(n) performance.
Hope that helps!