algorithm - Sorting in java with minimum time complexity -
i new java have sort array of order 10^6. time complexity of sort method
available in java. sorting algorithm should use?
assuming have no other knowledge of data , have use generic sort method, best theoretical in-place sort algorithm o(n*log(n)). arrays.sort method should using 1 of those, , best choice without more info.
if you're willing use lot of memory, can use non-in place sort such radix or counting. these can quicker n*log(n), quick o(n), may use o(n) or worse memory. if have knowledge of data having special properties (such being sorted) insertion sort or similar algorithms quicker o(n*log(n)) without using memory, without more info 1 of can't suggested.
Comments
Post a Comment