/*
* @(#)InsertionSortAlgorithm.java 1.0 98/10
* For Computer Science 510 Analysis of Algorithms
* San Francisco State University
* Fall 1998
*/
/*
* Copyright 1998, Charles Hall
* An insertion sort demonstration algorithm
* SortAlgorithm.java, Thu Oct 27 10:32:35 1994
*
* @author Chuck Hall
* @version 1.0, Oct 1998
*/
class InsertionSortAlgorithm extends SortAlgorithm {
void sort(int a[]) throws Exception {
int T;
int temp;
for(int i=1;i<=a.length;i++) {
if(stopRequested){
return;
}
T=a[i];
int j=i-1;
while(j>=0 && a[j]>T) {
temp=a[j];
a[j]=a[j+1];
a[j+1]=temp;
j--;
}//end swap
pause(i,j);
}//end for
}//end sort
}//end class InsertionSortAlgorithm
               (
geocities.com/siliconvalley/way)                   (
geocities.com/siliconvalley)