首页    期刊浏览 2024年11月05日 星期二
登录注册

文章基本信息

  • 标题:On the Worst-Case Complexity of TimSort
  • 本地全文:下载
  • 作者:Nicolas Auger ; Vincent Jug{\'e ; Cyril Nicaud
  • 期刊名称:LIPIcs : Leibniz International Proceedings in Informatics
  • 电子版ISSN:1868-8969
  • 出版年度:2018
  • 卷号:112
  • 页码:1-13
  • DOI:10.4230/LIPIcs.ESA.2018.4
  • 出版社:Schloss Dagstuhl -- Leibniz-Zentrum fuer Informatik
  • 摘要: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 rho), where rho 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.
  • 关键词:Sorting algorithms; Merge sorting algorithms; TimSort; Analysis of algorithms
国家哲学社会科学文献中心版权所有