Data Structures & AlgorithmsModerateTCS NQT · Infosys

Problem: The array [7, 3, 9, 1, 5] is processed by a selection that finds the position of the maximum, removes it, and repeats. The removal order gives a list of values in decreasing order. What is the value removed second?

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

Correct answer: C. 7

Removals happen in order 9, 7, 5, 3, 1, so the second removed is 7. The original second element (also the second smallest) is 3, 9 is removed first, and 5 is removed third.

More Coding Interview Problems questions

Exams that ask this topic