Data Structures & AlgorithmsHard

What is the MEDIAN of the combined multiset of the sorted arrays 1 3 8 9 and 2 4 6 7 10? (The combined size is odd, so take the middle value.)

  1. A. 7
  2. B. 2
  3. C. 9
  4. D. 6

Correct answer: D. 6

Merged order 1, 2, 3, 4, 6, 7, 8, 9, 10 has 9 values, so the median is the 5th smallest: 6. Taking the 6th gives 7, taking the middle of the unsorted concatenation gives 2, and 9 is the merged size, not a value.

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

Exams that ask this topic