Solution : Selection Sort after two iterations: 1 14 8 9 5 16 2 1 2 14 9 8 16 5 program: class Sorting { public static void main(String args[]) { int a[]=new int[]{8,14,2,9,5,16,1}; int i,j,k; for(i=0;i<2;i++) { for(j=i+1;j<7;j++) { if(a[i]>a[j]) { int temp=a[i]; a[i]=a[j]; a[j]=temp; } } for(k=0;k<7;k++) { System.out.print(a[k]+\" \"); } System.out.println(); } } } INsertion Sort: after 2 iterations 8 14 2 9 5 16 1 2 8 14 9 5 16 1 class Sorting { public static void main(String args[]) { int a[]=new int[]{14,8,2,9,5,16,1}; int i,j,k; for (j = 1; j < 7; j++) { int temp = a[j]; i = j-1; while ( (i > -1) && ( a [i] > temp ) ) { a [i+1] = a [i]; i--; } a[i+1] = temp; for(k=0;k<7;k++) { System.out.print(a[k]+\" \"); } System.out.println(); } } } Bubble Sort: after 1 Iteration: 8 2 9 5 14 1 16 class Sorting { public static void main(String args[]) { int a[]=new int[]{14,8,2,9,5,16,1}; int i,j,k,temp; for(i=0; i < 7; i++){ for(j=1; j < (7-i); j++){ if(a[j-1] > a[j]){ //swap the elements! temp = a[j-1]; a[j-1] = a[j]; a[j] = temp; } } for(k=0;k<7;k++) { System.out.print(a[k]+\" \"); } System.out.println(); } } }.