/**
* Average case performance: O(n^2)
* Best case performance: O(n)
* Worst case performance: O(n^2)
*/
public class InsertionSort {
/**
* @param a Array of integers which are sorted when returns.
*/
public static void sort(int[] a)
{
if(a==null||a.length==0)
return;
int temp;
for(int k=1; k<a.length; k++){
temp = a[k];
int j;
for(j=i; j>0 && a[j-1]>temp; j--){
a[j]=a[j-1];
}
a[j]=temp;
}
}
}