Data Structures & AlgorithmsHard

Using the sorted arrays 1 3 8 9 and 2 4 6 7 10 together, what is the 7-th smallest value (1-based) of the combined multiset?

  1. A. 8
  2. B. 7
  3. C. 9
  4. D. 0

Correct answer: A. 8

Merge the two sorted arrays in one pass by advancing whichever head is smaller, stopping at the k-th element. Taking the k-th element from one array alone ignores the other array.

More Arrays, Strings, Linked Lists, Stacks, Queues and Hashing questions

Exams that ask this topic