Reputation: 447
Suppose I want to use the mergesort algorithm. Does JAVA has a method/function which implements the mergesort algorithm?
Or do I have to "manually" code the algorithm?
I do not know JAVA at all.
Upvotes: 1
Views: 709
Reputation: 5399
Yes there is Arrays.sort (Object[] ), there is a source code sample from OpenJDK
Upvotes: 5
Reputation: 159754
You could use Collections.sort()
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.
Upvotes: 1
Reputation: 2496
No there isn't a merge sort out of the box. A simple google after 'java mergesort' should give you plenty of useful results
Upvotes: -2