Hill sort static int[] Shellsort (int[] array) {if (array! = NULL) { Int[] List = {9, 5, 3, 2, 1}; foreach (int k in list) {for (int i = k; i < array. Length; i++) {int current = Array[i]; int preindex = i-k; while (preindex >= 0 && preindex < array. Length && Current < Array[preindex]) {array[preindex + K] = Array[preindex]; Preindex = preindex-k; } Array[preindex + K] = current; }}} return array; }//Insert sort public int[] Insertsort (int[] array) {if (array! = NULL) { int k = 1;//uses the k variable, which is better extended to the shell sort for (iNT i = k; I < array. Length; i++) {int current = Array[i]; int preindex = i-k; while (preindex >= 0 && preindex < array. Length && Current < Array[preindex]) {array[preindex + K] = ARRAY[PR Eindex]; Preindex = preindex-k; } Array[preindex + K] = current; }} return array; }//Bubble sort public int[] Bubblesort (int[] array) {if (array! = NULL) { for (int i = 0; i < array. Length; i++) {for (int j = 1; j < Array. Length-i; J + +) {if (array[j-1] > Array[j]) { int temp = array[j-1]; ARRAY[J-1] = Array[j]; ARRAY[J] = temp; }}}} return array; }
C#_ Basics: Sorting Algorithms