Java Applets Centre
Bubble Sort


Description
This applet demonstrates the working of the Bubble Sort algorithm.


Code

public void bubbleSort(){
  int temp;
  for(int j=size-1; j > 0; j--){
   for(int i=0; i < j; i++){
    if(arr[i] > arr[i+1]){
     temp=arr[i];
     arr[i]=arr[j];
     arr[j]=temp;
    }
   }
  }
}


Data Structures and Algorithms
Java Applets Centre


R. Mukundan
Department of Computer Science
University of Canterbury
Private Bag 4800, Christchurch
New Zealand.