public class xierpx {
public static void q1(int[] arry) {
// TODO Auto-generated method stub
int incre = arry.length / 2;
while (incre >=1) {
int k = 0;
while (k
for (int i = incre+k; i < arry.length; i+=incre) {
int temp = arry[i];
int j;
for (j = i-incre; j >=0; j-=incre) {
if (temp < arry[j]) {
arry[j+incre] = arry[j];
}else break;
}
j+=incre;
arry[j] = temp;
}
k++;
}
incre/=2;
}
for (int i = 0; i < arry.length; i++) {
System.out.print(arry[i]+" ");
}
}
public static void main(String[] args) {
// TODO Auto-generated method stub
int[] arry1 = {1,4,2,8,5,9,2,6};
q1(arry1);
}
}