Skip to content
Related Articles

Related Articles

ISRO | ISRO CS 2017 – May | Question 48

View Discussion
Improve Article
Save Article
  • Last Updated : 21 Mar, 2018
View Discussion
Improve Article
Save Article

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
Recommended Articles
Page :

Start Your Coding Journey Now!