Which one of the following is the tightest upper bound that represents the number of swaps required to sort n numbers using selection sort?
Topic-wise GATE CS PYQs with verified steps
GATE CSE 2013 · Q6
Time
Select one answerSingle correct
Solution
Official answer: B) O(n)
Searching, Sorting and HashingIn selection sort, the algorithm divides the input list into two parts: a sorted sublist and an unsorted sublist. In each of the passes, it finds the minimum element from the unsorted sublist and places it at the beginning of the unsorted sublist using at most one swap.
Therefore, the maximum number of swaps performed by selection sort is , which is bounded by .
Thus, the tightest upper bound representing the number of swaps is (Option B).
Try the question first, then check your work.
Examiner trap
In each pass of selection sort, how many swaps are executed after finding the minimum element?
This Searching, Sorting and Hashing previous year question is Q6 of the GATE CSE 2013 paper. Find more GATE CSE PYQs on Searching, Sorting and Hashing in Algorithms, or browse all GATE CSE PYQs.
Free diagnostic
Take the 20-minute diagnostic: the 3 topics that cost you the most marks, and a rank range. Or sit 5 related Searching, Sorting and Hashing PYQs now with no account.
An official question by email at 7 AM IST, with a link to its verified solution. Unsubscribe in one click.
Searching, Sorting and Hashing has 27 GATE CSE PYQs across 20 papers from 2012 to 2026. 9 of them are 1-mark MCQs like this one, and GATE CSE 2013 has 2.
How GATE tests Searching, Sorting and HashingIndependent practice explanation verified by the GateAI team. GATE is conducted by the IITs; question text follows the official paper.