Re:On the Worst-Case Complexity of TimSort
by dmurray on Friday August 31, 2018 @08:34AM
(#17884980)
All sorting algorithms can trivially be made to perform in O(n) in the "already sorted" scenario without worsening the worst case complexity, so that isn't really helpful.
Re:On the Worst-Case Complexity of TimSort
by giovannibajo1 on Friday August 31, 2018 @12:03PM
(#17886642)
It can be done only by adding an initial check that does only that. But this means that the algorithm speed doesn’t gradually increase with partially sorted sequences.
For instance, timsort is also very fast if only a single element is unsorted, or only two elements, or only three elements. These are not special cases explicitly handled, its just the natural way the algorithm works.
In some other typical cases (otherwise sorted array with one element inserted, two sorted arrays appended to each other) rho is 3 and 2, so also O(n).