StreakPeaked· Practice

ExamsGATETechnical

Which one of the following is the tightest upper bound that represents the number of swaps required to sort n numbers using selection sort?

  1. O(log n)
  2. O(n)
  3. O(n log n)
  4. O(n²)

Correct answer: O(n)

Solution

Selection sort requires a linear number of swaps, specifically one swap for each of the n elements in the worst case, making O(n) the tightest upper bound for the number of swaps.

Related GATE Technical questions

⚔️ Practice GATE Technical free + battle 1v1 →