ISRO | ISRO CS 2017 – May | Question 48

The number of swappings needed to sort the numbers 8, 22, 7, 9, 31, 5, 13 in ascending order, using bubble sort is
(A) 11
(B) 12
(C) 13
(D) 10


Answer: (D)

Explanation: 1 : 8, 7, 9, 22, 5, 13, 31 = 4 swaps
2 : 7, 8, 9, 5, 13, 22, 31 = 3 swaps
3 : 7, 8, 5, 9, 13, 22, 31 = 1 swap
4 : 7, 5, 8, 9, 13, 22, 31 = 1 swap
5 : 5, 7, 8, 9, 13, 22, 31 = 1 swap
Total 10 swaps are required to sort the array.

Quiz of this Question



My Personal Notes arrow_drop_up


Article Tags :

Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.