Merge algorithm: Difference between revisions

Content deleted Content added
{{sorting}}
Line 16:
</div>
 
[[Best, worst and average case|In the worst case]], this algorithm performs {{math|(''k''−1)(''n''−{{sfrac|''k''/|2}})}} element comparisons to perform its work if there are a total of {{mvar|n}} elements in the sequences in total.<ref name="greene">{{cite conference |last=Greene |first=William A. |year=1993 |title=k-way Merging and k-ary Sorts |conference=Proc. 31-st Annual ACM Southeast Conf |pages=127–135}}</ref>
It can be improved by storing the sequences in a [[priority queue]] ([[heap (data structure)|min-heap]]) keyed by their first element: