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 ?

  1. A.

    67, 12, 10, 5, 4, 7, 23

  2. B.

    4, 7, 10, 23, 67, 12, 5

  3. C.

    4, 5, 7, 67, 10, 12, 23

  4. 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].

Explore the full course: Isro