GATE Computer ScienceModerateNIELIT Scientist B

Selection sort (find the minimum of the unsorted part and exchange it with the first unsorted position, skipping the exchange when the minimum is already in place) is run on [29, 10, 14, 37, 13, 5, 22, 8]. How many exchanges are performed?

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

Correct answer: C. 6

Simulating the passes gives 6 actual exchanges; passes whose minimum is already in place do nothing.

More Algorithms questions

Exams that ask this topic