Skip to content
GATEiit

GATE DA 2025 Q29: Insertion sort with exactly two swaps: possible values of x

Question

Suppose that insertion sort is applied to the array [1,3,5,7,9,11,x,15,13][1, 3, 5, 7, 9, 11, x, 15, 13] and it takes exactly two swaps to sort the array. Select all possible values of xx.

Try it: multiple select: one or more correct options

Select one or more options
Select all correct options. No negative marking, no partial marks.
Show answer and explanation

Answer: A, C (official GATE 2025 final answer key)

Concept used: The number of swaps in insertion sort equals the number of inversions in the array.

First step: The pair (15, 13) is already one inversion, so xx must create exactly one more. Count the inversions xx forms with the elements before and after it.

Full step-by-step solution

Detailed working, common mistakes and linked mock tests will be available with a free GATEiit account. Log-in is coming soon.

Share this question

WhatsAppDownload image

Source: official GATE 2025 DA question paper and final answer key, organised by IIT Roorkee. Question paper · Answer key