diff --git a/com/williamfiset/datastructures/shell sort b/com/williamfiset/datastructures/shell sort new file mode 100644 index 0000000..5f43b0a --- /dev/null +++ b/com/williamfiset/datastructures/shell sort @@ -0,0 +1,31 @@ +#include +void main() +{ +int arr[10]={-1}; + int i, j, n, flag = 1, gap_size, temp; + printf("\n Enter the number of elements in the array: "); + scanf("%d", &n); + printf("\n Enter %d numbers: ",n); // n was added + for(i=0;i 1) +{ + flag = 0; + gap_size = (gap_size + 1) / 2; + for(i=0; i< (n - gap_size); i++) + { + if( arr[i+gap_size] < arr[i]) + { + temp = arr[i+gap_size]; + arr[i+gap_size] = arr[i]; + arr[i] = temp; + flag = 0; + } + } +} + printf("\n The sorted array is: \n"); + for(i=0;i