diff --git a/Grade 10/Computer Science/ICS4U1/Sorting Methods/Shellsort List.md b/Grade 10/Computer Science/ICS4U1/Sorting Methods/Shellsort List.md index 2c3f643..fb99fee 100644 --- a/Grade 10/Computer Science/ICS4U1/Sorting Methods/Shellsort List.md +++ b/Grade 10/Computer Science/ICS4U1/Sorting Methods/Shellsort List.md @@ -31,7 +31,7 @@ The space complexity of shell sort will always be **O(1)** as it does not create |$`4^k+3\times2^{k-1}+1`$|$`1, 8, 23, 77, 281`$|$`O(N^\frac{4}{3})`$|Sedgewick - 1982| ## Sample Program -``` +```java public static void shellSort(int arr[]) // Method Header { for(int gap = arr.length / 2; gap > 0; gap /= 2){ // Loop through the length of the gap sequences @@ -53,4 +53,15 @@ public static void shellSort(int arr[]) // Method Header - The gap sequence would be h1 and hn+1 = 3hn+1 - For 100 elements, shell's original gap seuqence will make 170 comparisons but the Enhanced Shell Sort will make 85 comparisons +## Testing +`10 Elements: 100, 37, 12, 86, 2, 127, 62, 14, 3, 9`
+**Shell Sort:** 30
+**Enhanced Shell Sort:** 12 + +`25 Elements: 100, 37, 12, 86, 2, 127, 62, 14, 3, 9, 30, 14, 90, 1, 20, 30, 74, 48, 37, 40, 7, 101, 200`
+**Shell Sort:** 47
+**Ehanced Shell Sort:** 31 + +`35 Elements: 1,2,23,12,25,7,9,5,36,1,100,37,12,86,2,127,62,14,3,9,30,14, 90,1,20,30,74,48,37,40,7,101,200,4,9 `
+