Bubble Sort Algorithm - Java Applet Visualization

The gadget spec URL could not be found
Bubble Sort : 

This works by travelling down the array , from the first to the last element ; comparing each pair of elements and swapping them if required . The worst case scenario is the sorted array in reverse order . The complexity of this is always O(n^2) ; and it is too inefficient to be used for most practical purposes . 

( Assuming a Zero based array ) 

for i -> 0 to lastIndex - 1 
for j -> i to lastIndex 
  if array[i] < array[j]
   swap(array[i],array[j])
next j
next i

"Start" the Visualization below :


Comments