+ 1

Give an example of bubble sorting in single dimensional array.

2nd Oct 2017, 1:37 PM
Ashish Upadhyay
Ashish Upadhyay - avatar
2 Réponses
+ 1
the idea is that the high numbers "bubble" up to the top (the end) 5,7,2,6 - initial order of numbers in the array iteration 1 (5,7),2,6 - no swap because 5<7 5,(7,2),6 - swap because 7>2 5,2,(7,6) - swap because 7>6 iteration 2 (5,2),6,7 - swap because 5>2 2,(5,6),7 - no swap because 5<6 2,5,(6,7) - no swap because 6<7 at this point the numbers are sorted, but the algorithm will go through once more to check
2nd Oct 2017, 2:02 PM
forrest
+ 1
Conceptually, +info: https://code.sololearn.com/WRK8Y6Bkj9eP/?ref=app / Burey also linked to some YouTube videos of dancers sorting themselves but haven't found that here yet.
2nd Oct 2017, 2:13 PM
Kirk Schafer
Kirk Schafer - avatar