Bubble Sort
Pseudocode
BUBBLE_SORT(array)
for i := 1 to length(array)
for j := 1 to length(array) - i
if array[j] > array[j+1]
swap(array[j], array[j+1])BUBBLE_SORT(array)
sentinel := 1
for i := 1 to length(array)
if sentinel = 1
break
for j := 1 to length(array) - i
if array[j] > array[j+1]
swap(array[j], array[j+1])
sentinel := 0Algorithm Analysis
Last updated
Was this helpful?