Multiway blockwise in-place merging.

Viliam Geffert, Jozef Gajdoš · 2008

Abstract. We present an algorithm for asymptotically efficient multiway blockwise in-place merging. Given an array A containing sorted subsequences A1,..., Ak of respective lengths n1,..., nk, where ∑k ni = n, we assume i=1 that extra k·s elements (so called buffer elements) are positioned at the very end of array A, and that the lengths n1,..., nk are positive integer multiples of some parameter s (i.e., multiples of a given block of length s). The number of input sequences k is a fixed constant parameter, not dependent on the lengths of input sequences. Then our algorithm merges the subsequences A1,..., Ak into a single sorted sequence, performing Θ(log k·n) + O((n/s) 2) + O(s· log s) element comparisons and 3·n + O(s·log s) element moves. 1 Then, for s = ⌈n 2/3 /(log n) 1/3 ⌉, this gives an algorithm performing Θ(log k·n) + O((n·log n) 2/3) comparisons and 3·n + O((n·log n) 2/3) moves. That is, our algorithm runs in linear time, with an asymptotically optimal number of comparisons and with the number of moves independent on the number of input sequences. Moreover, our algorithm is “almost in-place”, it requires only k extra blocks of size s = o(n). 1

Read the paper · More papers on PaperTik