Let be the total length of the two runs in merge . Because destinations are always appended beyond the old endpoint, the exact space consumption is
A simple valid bound is , using at most merges. The FIFO queue schedule permits the sharper asymptotic bound
To prove the upper bound, group merges into rounds. Mark the old end of the live segment, and finish a round when all runs present at its start have been consumed. If there are such runs, at most merges occur. Only the last merge can pair one remaining old run with an already appended run. Consequently at most runs remain; coalescence can only reduce this number. Every start-of-round entry is merged once, and entries in the one possible already appended run are merged at most once more. A round writes at most entries. After at most rounds there is one run, giving for .
For a matching family, let and use repetitions of . Each initial run has length two. Every merged run still starts at zero and ends at one, so adjacent runs never coalesce. In each of the complete merging levels exactly entries are written. Hence
on this family. For an already sorted input, no merge occurs and .

Articles by others on the same topic (0)

There are currently no matching articles.