Source of BubbleSortAlgorithm.java


  1: class BubbleSortAlgorithm extends SortAlgorithm {
  2:   void sort(int a[]) {
  3:     for (int i = a.length; --i>=0; )
  4:       for (int j = 0; j<i; j++) {
  5:         if (a[j] > a[j+1])
  6:           swap(a, j, j+1);
  7:         pause();
  8:       }
  9:   }
 10: 
 11:   public BubbleSortAlgorithm(AlgorithmAnimator animator) {
 12:     super(animator); 
 13:   }
 14: }