Does max() sort the array first?
Array max()
Add a Comment
Does max() sort the array first?
Does max() sort the array first?
No, it scans the unordered array from first to last.
Generally simple max() takes O(n), and sorting takes O(n*log(n)). Sorting is not a good starategy when you need one maximum value.
One more, `max()` is a method defined in Swift Standard Library, so, Cocoa Touch is not a good place to ask.
Does max() sort the array first?
No, it scans the unordered array from first to last.
Generally simple max() takes O(n), and sorting takes O(n*log(n)). Sorting is not a good starategy when you need one maximum value.
One more, `max()` is a method defined in Swift Standard Library, so, Cocoa Touch is not a good place to ask.