Java Applets Centre
Insertion Sort


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


Code

public void insertionSort(){
  int i,k,temp;
  for(k=1; k < n; k++){
   temp=a[k];
   i=k;
   while(i > 0 && temp < a[i-1]){
    a[i]=a[i-1];
    i--;
   }
   a[i]=temp;
  }
}


Data Structures and Algorithms
Java Applets Centre


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