Given an array as [22, 20 30, 10, 2, 8]. What will be the position of element 2 after 2 iterations of selection sort and insertion sort, respectively?
Note: Indexing of the array starts from 0.
(A) 0
(B) 3
(C) 4
(D) 5
Given an array as [22, 20 30, 10, 2, 8]. What will be the position of element 2 after 2 iterations of selection sort and insertion sort, respectively?
Note: Indexing of the array starts from 0.
(A) 0
(B) 3
(C) 4
(D) 5
Solution
✅ Correct Option: 2
The array is read as [22, 20, 30, 10, 2, 8].
Selection sort picks the smallest remaining element each pass and swaps it into place. Insertion sort takes the next element and inserts it into the sorted prefix. This leaves 2 untouched in the second case.
| Iteration | Selection sort | Insertion sort |
|---|---|---|
| Start | [22, 20, 30, 10, 2, 8] | [22, 20, 30, 10, 2, 8] |
| 1 | [2, 20, 30, 10, 22, 8] (2 swapped with 22) | [20, 22, 30, 10, 2, 8] (20 inserted before 22) |
| 2 | [2, 8, 30, 10, 22, 20] (8 swapped with 20) | [20, 22, 30, 10, 2, 8] (30 already in place) |
| Index of 2 | 0 | 4 |
Related questions:
2026: 19 May Shift 1
2025: 20 May Shift 1
2026: 21 May Shift 1
2026: 26 May Shift 1