Java code for shell sorting.
class ShellSort {
public static void main(String args[]) {
int[] array = new int[] {
3, 21, 0, 49, 7, 91, 110, 000, 14
};
int i, j, k, increment, temp, elements = array.length;
/* Shell Sort Program */
for (increment = elements / 2; increment > 0; increment /= 2) {
for (j = increment; j < elements; j++) {
temp = array[j];
for (k = j; k >= increment; k -= increment) {
if (temp < array[k - increment]) {
array[k] = array[k - increment];
} else {
break;
}
}
array[k] = temp;
}
}
System.out.println("After Sorting we get:");
for (i = 0; i < 9; i++) {
System.out.println(array[i]);
}
}
}Thank you, keep learning sharing
