Data Structures & AlgorithmsModerateICPC regional · algorithm theory

Problem: What is the worst-case number of comparisons to merge two sorted lists of lengths m and n?

  1. A. m + n - 1
  2. B. max(m, n)
  3. C. m * n * 2
  4. D. m + n

Correct answer: A. m + n - 1

Each comparison outputs one element, and the last element needs no comparison, giving m + n - 1.

More Coding Interview Problems questions

Exams that ask this topic