Gradient LabSign up free

Home / GATE DA / 2024 / Q.45

GATE DA 2024, Q.45: Which sorts finish [4, 3, 2, 1, 5] in two passes

Data structures and algorithmsSorting algorithm passes2 marksMCQFree

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?

Watch it solved

Solve it step by step

  1. Selection. Pass 1 puts 1 first: [1, 3, 2, 4, 5]. Pass 2 puts 2 second: [1, 2, 3, 4, 5]. Sorted.
  2. Bubble. Pass 1: [3, 2, 1, 4, 5]. Pass 2: [2, 1, 3, 4, 5]. Not sorted.
  3. Insertion. Pass 1: [3, 4, 2, 1, 5]. Pass 2: [2, 3, 4, 1, 5]. Not sorted.
  4. 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 sheets

Source: official GATE DA 2024 question paper and answer key (IISc Bengaluru). The question is lightly reworded; every number and option is kept.