Skip to content

ISRO Scientist/Engineer CSE 2020Algorithms › Sorting

ISRO Scientist/Engineer CSE 2020 PYQ: If an array $A$ contains the items 10,4,7,23,67,12 and 5 in that order, what will be the resultant array $A$…

If an array $A$ contains the items 10,4,7,23,67,12 and 5 in that order, what will be the resultant array $A$ after third pass of insertion sort?

  1. A
    67,12,10,5,4,7,23
  2. B
    4,7,10,23,67,12,5
    Correct answer
  3. C
    4,5,7,67,10,12,23
  4. D
    10,7,4,67,23,12,5

Answer

(B) $4,7,10,23,67,12,5$

Approach

Insertion sort builds a sorted prefix one element at a time. The k-th pass inserts the (k+1)-th element into its correct position among the first k+1 elements. We simulate the first three passes on the given array.

Reviewed by ISRO IQ Editorial Team.