Galloping in Fast-Growth Natural Merge Sorts

IF 0.9 4区 计算机科学 Q4 COMPUTER SCIENCE, SOFTWARE ENGINEERING Algorithmica Pub Date : 2024-12-09 DOI:10.1007/s00453-024-01285-6
Elahe Ghasemi, Vincent Jugé, Ghazal Khalighinejad, Helia Yazdanyar
{"title":"Galloping in Fast-Growth Natural Merge Sorts","authors":"Elahe Ghasemi,&nbsp;Vincent Jugé,&nbsp;Ghazal Khalighinejad,&nbsp;Helia Yazdanyar","doi":"10.1007/s00453-024-01285-6","DOIUrl":null,"url":null,"abstract":"<div><p>We study the impact of merging routines in merge-based sorting algorithms. More precisely, we focus on the <i>galloping</i> routine that TimSort uses to merge monotonic sub-arrays, hereafter called <i>runs</i>, and on the impact on the number of element comparisons performed if one uses this routine instead of a naïve merging routine. This routine was introduced in order to make TimSort more efficient on arrays with few distinct values. Alas, we prove that, although it makes TimSort sort array with two values in linear time, it does not prevent TimSort from requiring up to <span>\\(\\Theta (n \\log (n))\\)</span> element comparisons to sort arrays of length <i>n</i> with three distinct values. However, we also prove that slightly modifying TimSort ’s galloping routine results in requiring only <span>\\(\\mathcal {O}(n + n \\log (\\sigma ))\\)</span> element comparisons in the worst case, when sorting arrays of length <i>n</i> with <span>\\(\\sigma \\)</span> distinct values. We do so by focusing on the notion of <i>dual runs</i>, which was introduced in the 1990s, and on the associated <i>dual run-length entropy</i>. This notion is both related to the number of distinct values and to the number of runs in an array, which came with its own <i>run-length entropy</i> that was used to explain TimSort ’s otherwise “supernatural” efficiency. We also introduce new notions of <i>fast-</i> and <i>middle-growth</i> for natural merge sorts (i.e., algorithms based on merging runs), which are found in several sorting algorithms similar to TimSort. We prove that algorithms with the fast- or middle-growth property, provided that they use our variant of TimSort ’s galloping routine for merging runs, are as efficient as possible at sorting arrays with low run-induced or dual-run-induced complexities.\n</p></div>","PeriodicalId":50824,"journal":{"name":"Algorithmica","volume":"87 2","pages":"242 - 291"},"PeriodicalIF":0.9000,"publicationDate":"2024-12-09","publicationTypes":"Journal Article","fieldsOfStudy":null,"isOpenAccess":false,"openAccessPdf":"","citationCount":"0","resultStr":null,"platform":"Semanticscholar","paperid":null,"PeriodicalName":"Algorithmica","FirstCategoryId":"94","ListUrlMain":"https://link.springer.com/article/10.1007/s00453-024-01285-6","RegionNum":4,"RegionCategory":"计算机科学","ArticlePicture":[],"TitleCN":null,"AbstractTextCN":null,"PMCID":null,"EPubDate":"","PubModel":"","JCR":"Q4","JCRName":"COMPUTER SCIENCE, SOFTWARE ENGINEERING","Score":null,"Total":0}
引用次数: 0

Abstract

We study the impact of merging routines in merge-based sorting algorithms. More precisely, we focus on the galloping routine that TimSort uses to merge monotonic sub-arrays, hereafter called runs, and on the impact on the number of element comparisons performed if one uses this routine instead of a naïve merging routine. This routine was introduced in order to make TimSort more efficient on arrays with few distinct values. Alas, we prove that, although it makes TimSort sort array with two values in linear time, it does not prevent TimSort from requiring up to \(\Theta (n \log (n))\) element comparisons to sort arrays of length n with three distinct values. However, we also prove that slightly modifying TimSort ’s galloping routine results in requiring only \(\mathcal {O}(n + n \log (\sigma ))\) element comparisons in the worst case, when sorting arrays of length n with \(\sigma \) distinct values. We do so by focusing on the notion of dual runs, which was introduced in the 1990s, and on the associated dual run-length entropy. This notion is both related to the number of distinct values and to the number of runs in an array, which came with its own run-length entropy that was used to explain TimSort ’s otherwise “supernatural” efficiency. We also introduce new notions of fast- and middle-growth for natural merge sorts (i.e., algorithms based on merging runs), which are found in several sorting algorithms similar to TimSort. We prove that algorithms with the fast- or middle-growth property, provided that they use our variant of TimSort ’s galloping routine for merging runs, are as efficient as possible at sorting arrays with low run-induced or dual-run-induced complexities.

Abstract Image

查看原文
分享 分享
微信好友 朋友圈 QQ好友 复制链接
本刊更多论文
求助全文
约1分钟内获得全文 去求助
来源期刊
Algorithmica
Algorithmica 工程技术-计算机:软件工程
CiteScore
2.80
自引率
9.10%
发文量
158
审稿时长
12 months
期刊介绍: Algorithmica is an international journal which publishes theoretical papers on algorithms that address problems arising in practical areas, and experimental papers of general appeal for practical importance or techniques. The development of algorithms is an integral part of computer science. The increasing complexity and scope of computer applications makes the design of efficient algorithms essential. Algorithmica covers algorithms in applied areas such as: VLSI, distributed computing, parallel processing, automated design, robotics, graphics, data base design, software tools, as well as algorithms in fundamental areas such as sorting, searching, data structures, computational geometry, and linear programming. In addition, the journal features two special sections: Application Experience, presenting findings obtained from applications of theoretical results to practical situations, and Problems, offering short papers presenting problems on selected topics of computer science.
期刊最新文献
Popular Roommates in Simply Exponential Time Galloping in Fast-Growth Natural Merge Sorts Line Intersection Searching Amid Unit Balls in 3-Space Partition Strategies for the Maker–Breaker Domination Game Optimal Algorithms for Online b-Matching with Variable Vertex Capacities
×
引用
GB/T 7714-2015
复制
MLA
复制
APA
复制
导出至
BibTeX EndNote RefMan NoteFirst NoteExpress
×
×
提示
您的信息不完整,为了账户安全,请先补充。
现在去补充
×
提示
您因"违规操作"
具体请查看互助需知
我知道了
×
提示
现在去查看 取消
×
提示
确定
0
微信
客服QQ
Book学术公众号 扫码关注我们
反馈
×
意见反馈
请填写您的意见或建议
请填写您的手机或邮箱
已复制链接
已复制链接
快去分享给好友吧!
我知道了
×
扫码分享
扫码分享
Book学术官方微信
Book学术文献互助
Book学术文献互助群
群 号:481959085
Book学术
文献互助 智能选刊 最新文献 互助须知 联系我们:info@booksci.cn
Book学术提供免费学术资源搜索服务,方便国内外学者检索中英文文献。致力于提供最便捷和优质的服务体验。
Copyright © 2023 Book学术 All rights reserved.
ghs 京公网安备 11010802042870号 京ICP备2023020795号-1