How many swaps are required to sort the given array using bubble sort - { 2,…

2023

How many swaps are required to sort the given array using bubble sort - { 2, 5, 1, 3, 4}

  1. A.

    4

  2. B.

    5

  3. C.

    6

  4. D.

    7

Attempted by 201 students.

Show answer & explanation

Correct answer: A

Answer : A

Explanation

There will be 3 swaps in first iteration and 1 swap in second iteration.

Explore the full course: Coding For Placement