Last Updated : 14 Nov, 2018

Consider the following list of the integer:

19, 23, 40, 32, 91, 25, 100, 36 

Sort this list in increasing order using insertion sort and determine the number of passes, comparisons, and swaps ?

(A) 7, 14, 8 respectively.
(B) 7, 7, 14 respectively.
(C) 8, 7, 12 respectively.
(D) 8, 14, 7 respectively.


Answer: (D)

Explanation: According to Insertion Sort, there will be total 8 passes for all 8 integers. Number of comparisons and Swaps for each pass for given sequences to sort in increasing order:

Comparisons: 0, 1, 1, 2, 1, 4, 1, 4 = 14 
Swaps: 0, 0, 0, 1, 0, 3, 0, 3 = 7 

So, option (D) is correct.

Quiz of this Question


Share your thoughts in the comments