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?
- A67,12,10,5,4,7,23
- B4,7,10,23,67,12,5Correct answer
- C4,5,7,67,10,12,23
- D10,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.