Abstract

The problem of merging sorted lists in the least number of pairwise comparisons has been solved completely only for a few special cases. Graham and Karp (Sorting Search 3:197–207, 1999) independently discovered that the tape merge algorithm is optimal in the worst case when the two lists have the same size. In their seminal papers, Stockmeyer and Yao (SIAM J Comput 9(1):85–90, 1980), Murphy and Paull (Inf Control 42(1):87–96, 1979), and Christen (On the optimality of the straight merging algorithm, 1978) independently showed when the lists to be merged are of size m and n satisfying $$m\le n\le \lfloor \frac{3}{2}m\rfloor +1$$, the tape merge algorithm is optimal in the worst case. This paper extends this result by showing that the tape merge algorithm is optimal in the worst case whenever the size of one list is no larger than 1.52 times the size of the other. The main tool we use to prove the lower bound is Knuth’s (1999) adversary methods. In addition, we show that the lower bound cannot be improved to 1.8 via Knuth’s adversary methods. Moreover, we design a simple procedure, and by invoking this procedure recursively until the remaining subproblem can be solved efficiently by another known algorithm, we achieve constant improvement of the upper bound for $$2m-2\le n\le 3m $$.

Highlights

  • Suppose there are two disjoint linearly ordered lists A and B: a1 < a2 < · · · < am and b1 < b2 < · · · < bn respectively, where the m + n elements are distinct

  • + 1, the tape merge algorithm is optimal in the worst case. This paper extends this result by showing that the tape merge algorithm is optimal in the worst case whenever the size of one list is no larger than 1.52 times the size of the other

  • Leibniz International Proceedings in Informatics Schloss Dagstuhl – Leibniz-Zentrum für Informatik, Dagstuhl Publishing, Germany 51:2 On the Optimality of Tape Merge of Two Lists with Similar Size comparison-based model, where the algorithm is a sequence of pairwise comparisons

Read more

Summary

Introduction

Suppose there are two disjoint linearly ordered lists A and B: a1 < a2 < · · · < am and b1 < b2 < · · · < bn respectively, where the m + n elements are distinct. Hwang and Deutsch[13] designed an algorithm which is optimal over all insertive algorithms including binary merge, where for each element of the smaller list, the comparisons involving it are made consecutively. The idea is that the optimal merge problem can be viewed as a two-player game with perfect information, in which the algorithm chooses the comparisons, while the adversary chooses (consistently) the results of these comparisons. Knuth proposed the idea of using of "disjunctive" strategies, in which a splitting of the remaining problem into two disjoint problems is provided, in addition to the result of the comparison With this restricted adversary, he used term .M.(m, n) to represent the minimum number of comparisons required in the algorithm, which is a lower bound of M (m, n).

Our Results
Related work
Preliminaries
Inequalities about Knuth’s adversary methods
Limitations of Knuth’s adversary methods
Conclusion
A Proof of Lemma 6
B Proof of Theorem 8
Full Text
Published version (Free)

Talk to us

Join us for a 30 min session where you can share your feedback and ask us any queries you have

Schedule a call