Skip to main contentSkip to solution

The selection sort on a list of 'n' elements has _______ number of passes.

Solution

✅ Correct Option: 4

Selection sort finds the smallest element in the unsorted part and swaps it into its correct position, one position per pass. After n−1n-1 passes, the first n−1n-1 elements are in their final places, so the last element is automatically correct and needs no pass of its own.


Option 1: a common mistake. The last element never needs its own pass.

Option 3: n2n^2 describes the time complexity, O(n2)O(n^2), not the number of passes.

Total comparisons are n(n−1)2\dfrac{n(n-1)}{2}, which is where the O(n2)O(n^2) comes from.

Keyboard Shortcuts

  • Left arrow: Previous question
  • Right arrow: Next question
  • S key: Jump to solution
  • Q key: Jump to question