On the Worst-Case Complexity of TimSort - Archive ouverte HAL Accéder directement au contenu
Communication Dans Un Congrès Année : 2018

On the Worst-Case Complexity of TimSort

Résumé

TimSort is an intriguing sorting algorithm designed in 2002 for Python, whose worst-case complexity was announced, but not proved until our recent preprint. In fact, there are two slightly different versions of TimSort that are currently implemented in Python and in Java respectively. We propose a pedagogical and insightful proof that the Python version runs in O(n log n). The approach we use in the analysis also applies to the Java version, although not without very involved technical details. As a byproduct of our study, we uncover a bug in the Java implementation that can cause the sorting method to fail during the execution. We also give a proof that Python's TimSort running time is in O(n+n log ρ), where ρ is the number of runs (i.e. maximal monotonic sequences), which is quite a natural parameter here and part of the explanation for the good behavior of TimSort on partially sorted inputs.
Fichier principal
Vignette du fichier
timsort2018.pdf (790.44 Ko) Télécharger le fichier
Origine : Fichiers produits par l'(les) auteur(s)
Loading...

Dates et versions

hal-01798381 , version 1 (23-05-2018)

Identifiants

Citer

Nicolas Auger, Vincent Jugé, Cyril Nicaud, Carine Pivoteau. On the Worst-Case Complexity of TimSort. 26th Annual European Symposium on Algorithms (ESA 2018), Aug 2018, Helsinki, Finland. pp.4:1--4:13, ⟨10.4230/LIPIcs.ESA.2018.4⟩. ⟨hal-01798381⟩
239 Consultations
725 Téléchargements

Altmetric

Partager

Gmail Facebook X LinkedIn More