diff --git a/14.c b/14.c new file mode 100644 index 0000000..fc183f5 --- /dev/null +++ b/14.c @@ -0,0 +1,31 @@ +#include +#include + +void shell_sort(int arr[], int n) { + for (int g = n / 2; g > 0; g /= 2) { + for (int i = g; i < n; i++) { + int x = arr[i], j; + for (j = i; j >= g && arr[j - g] > x; j -= g) + arr[j] = arr[j - g]; + arr[j] = x; + } + } +} + +void display(int arr[], int n) { + for (int i = 0; i < n; i++) + printf("%d ", arr[i]); + printf("\n"); +} + +int main() { + const int SIZE = 5; + + int arr[] = {93, 110, 12398, -5, 2}; + printf("Insertion Sort on: "); + display(arr, SIZE); + shell_sort(arr, SIZE); + display(arr, SIZE); + + return 0; +} diff --git a/14.png b/14.png new file mode 100644 index 0000000..2d19cc7 Binary files /dev/null and b/14.png differ