Buble Sort
Buble Sort
Sorting
• Sorting takes an unordered collection and
makes it an ordered one.
1 2 3 4 5 6
77 42 35 12 101 5
1 2 3 4 5 6
5 12 35 42 77 101
"Bubbling Up" the Largest Element
1 2 3 4 5 6
77 42 35 12 101 5
"Bubbling Up" the Largest Element
1 2 3 4 5 6
42Swap77 12 101
77 42 35 5
"Bubbling Up" the Largest Element
1 2 3 4 5 6
42 35Swap35
77 77 12 101 5
"Bubbling Up" the Largest Element
1 2 3 4 5 6
42 35 12Swap12
77 77 101 5
"Bubbling Up" the Largest Element
1 2 3 4 5 6
42 35 12 77 101 5
No need to swap
"Bubbling Up" the Largest Element
1 2 3 4 5 6
42 35 12 77 5 Swap101
101 5
"Bubbling Up" the Largest Element
1 2 3 4 5 6
42 35 12 77 5 101