+ 1
How does bubble sort work?
I've tried to use bubble sort, but it shows incorrect result. What I did wrong? https://code.sololearn.com/cjAFK3xV9Vhp/?ref=app
2 Respostas
+ 1
You are only doing one iteration.
As you see, the largest number is at the right position.
Apply it n times (where n is the array size) and you will definitely get the correct result.
You can also think about how to adjust the indices, so that you don't compare already sorted numbers in the next iterations.
+ 1
It helped, thx.