Professional Documents
Culture Documents
Bubble Sort
Bubble Sort
8 5 9 3 (4 numbers)
Total 4 Numbers
So total number of passes to execute = 4-1 = 3
Pass 1:
Compare 1 & 2nd numbers
8>5 (Swapping)
5 8 9 3
Compare 2 & 3 rd numbers in the list
8>9 (False - no swap)
5 8 9 3
Compare 3rd and 4th number in the list
9>3 (swapping)
5 8 3 9
Pass 2: