If the array A contains the items 10, 4, 7, 23, 67, 12 and 5 in that order,…
2020
If the 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 ?
- A.
67, 12, 10, 5, 4, 7, 23
- B.
4, 7, 10, 23, 67, 12, 5
- C.
4, 5, 7, 67, 10, 12, 23
- D.
10, 7, 4, 67, 23, 12, 5
Attempted by 255 students.
Show answer & explanation
Correct answer: B
Initial array: [10, 4, 7, 23, 67, 12, 5]. Pass 1: Insert 4 before 10 -> [4, 10, 7, 23, 67, 12, 5]. Pass 2: Insert 7 between 4 and 10 -> [4, 7, 10, 23, 67, 12, 5]. Pass 3: Insert 23 after 10 -> [4, 7, 10, 23, 67, 12, 5]. After the third pass, the array is [4, 7, 10, 23, 67, 12, 5].