Monday, June 3, 2024
 Popular · Latest · Hot · Upcoming
169
rated 0 times [  172] [ 3]  / answers: 1 / hits: 52158  / 5 Years ago, mon, september 2, 2019, 12:00:00

According to Mozilla documentation :




The time and space complexity of the sort cannot be guaranteed as it
depends on the implementation.




Is it at least safe to assume that it's not O(n^2)? Is there anywhere more detailed data about how it's implemented ? Thanks.


More From » javascript

 Answers
1

Firefox uses merge sort. Chrome, as of version 70, uses a hybrid of merge sort and insertion sort called Timsort.



The time complexity of merge sort is O(n log n). While the specification does not specify the sorting algorithm to use, in any serious environment, you can probably expect that sorting larger arrays does not take longer than O(n log n) (because if it did, it would be easy to change to a much faster algorithm like merge sort, or some other log-linear method).



While comparison sorts like merge sort have a lower bound of O(n log n) (i.e. they take at least this long to complete), Timsort takes advantages of runs of already ordered data and so has a lower bound of O(n).


[#51702] Monday, August 26, 2019, 5 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
quinn

Total Points: 160
Total Questions: 86
Total Answers: 101

Location: Belarus
Member since Tue, Mar 14, 2023
1 Year ago
;