Save
SLR25/26 - Algorithms
Bubble Sort
Save
Share
Learn
Content
Leaderboard
Learn
Created by
M
Visit profile
Cards (2)
Steps on how a bubble sort works:
Compare each pair of
adjacent
elements
If they are not in the correct order then
swap
the elements
If they are in the correct order then do not swap elements
When you reach the end of the array return to the
start
Repeat n elements time
Set a flag to be
false
whenever a swap is made
Repeat the loop if the flag is not false
Code for
bubble
sort: