What is the total number of swaps performed to sort the following list of…

2023

What is the total number of swaps performed to sort the following list of elements 18, 32, 17, 19, 41, 15, 23 in an ascending order, using bubble sort?

Answer: C. 10In bubble sort, the number of swaps equals the number of inversions in the list. For 18, 32, 17, 19, 41, 15, 23 there are 10 inversions, so 10 swaps are…

  1. A.

    12

  2. B.

    13

  3. C.

    10

  4. D.

    11

Attempted by 334 students.

Show answer & explanation

Correct answer: C

In bubble sort, the number of swaps equals the number of inversions in the list. For 18, 32, 17, 19, 41, 15, 23 there are 10 inversions, so 10 swaps are performed.

Explore the full course: Coal India Management Trainee

Loading lesson…