GATE DA 2024, Q.45: Which sorts finish [4, 3, 2, 1, 5] in two passes
The question
Which of (i) bubble sort, (ii) insertion sort, (iii) selection sort sort [4, 3, 2, 1, 5] into increasing order after exactly two passes?
- (A) (i) only
- (B) (iii) only
- (C) (i) and (iii) only
- (D) (ii) and (iii) only
Watch it solved
Solve it step by step
- Selection. Pass 1 puts 1 first: [1, 3, 2, 4, 5]. Pass 2 puts 2 second: [1, 2, 3, 4, 5]. Sorted.
- Bubble. Pass 1: [3, 2, 1, 4, 5]. Pass 2: [2, 1, 3, 4, 5]. Not sorted.
- Insertion. Pass 1: [3, 4, 2, 1, 5]. Pass 2: [2, 3, 4, 1, 5]. Not sorted.
- Answer. Only selection sort: B.
Answer: (B) (iii) only
Official IISc Bengaluru answer key: B.
Common mistake. Assuming bubble sort finishes because the largest values look settled; bubble only fixes the end of the array.
Remember. Selection sort fixes the front one element per pass; bubble sort fixes the back.
Want every question solved? The past-paper pack has all 195 questions from 2024, 2025 and 2026 for ₹499. The cheat sheet pack has 23 printable sheets for ₹399.
See the past-paper pack See the cheat sheetsSource: official GATE DA 2024 question paper and answer key (IISc Bengaluru). The question is lightly reworded; every number and option is kept.