Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

9
  • 2
    There's no way to do fewer comparisons than in the "simple merge algorithm". You can try to handle edge cases like the first you mention, but this will worsen the average case. Commented Dec 26, 2014 at 12:48
  • 5
    @Mephy: enlighten us and give us a formal prove, please. Or if you can't, consider to delete (or at least refine) your comment. Commented Dec 26, 2014 at 13:05
  • 4
    @DocBrown if I had a formal proof, I would give an answer, not a comment. Anyway, it is a pretty obvious linear problem, because trying to find a better-than-linear solution would need at least linear time. Commented Dec 26, 2014 at 14:17
  • 4
    @Mephy: I suggest you take the time to read the answer below, and think twice about what you wrote. Commented Dec 26, 2014 at 15:49
  • 4
    @Mephy Most things that are obvious ("you can't do multiplication in less than O(n^2)", "if I change which door I picked I won't improve my chances to win a price", "you can't sort in less than O(n log n)",..) are wrong. Using a binary search approach on the shorter list for example should conceivably improve the average case. Commented Dec 26, 2014 at 16:41