Data Structures & AlgorithmsModerateTCS NQT Digital · Infosys

Problem: A list starts as [8, 3, 5]. Three insertion steps add the numbers 4, 9, 1 at the front of the list (each is inserted at index 0), and then the list is sorted in increasing order. What is the median of the final sorted list?

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

Correct answer: D. 5

Insert each value at the front, sort, and take the middle element of the six-element list. Sorting the original list alone gives a different median.

More Coding Interview Problems questions

Exams that ask this topic