If you are using bubble sort for sorting the given numbers in acsending order then findout number of swappings needed. 7,6,5,8,9

Answers 2

Answer:

Therefore, the number of swapping needed for arranging the numbers in ascending order is 12.

The total number of swapping required for sorting the array= {7,6,5,8,9}   in the acsending order is 3.

  • In bubble sort, we iterate through whole arrays and compare value of adjacent pair of number, and swap if 2nd number is smaller than the first number.
  • Array element : 7,6,5,8,9
  1. In the first iteration, the output will be 6,5,7,8,9 and total swaps are 2
  2. In the second iteration, the output will be 5,6,7,8,9 and total swaps are 1
  • The array is now sorted after 2nd iteration. Therefore total swaps made are (2+ 1) = 3 . Total of three swaps are required to sort these number in ascending order using bubble sort.

If you know the answer add it here!

Can't find the answer?

Log in with Google

or

Forgot your password?

I don't have an account, and I want to Register

Choose a language and a region
How much to ban the user?
1 hour 1 day 100 years