Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR SHELL

shell sort visualization

public void shellSort(int[] array) {
     int[] gaps = { 16, 30, 95, 51, 84, 23, 62, 44 };
     int temp;
     int i, j;

     for (int gap : gaps) {
          for (i = gap; i < array.length; i++) {
               temp = array[ i ];
               for (j = i; j >= gap && array[ j - gap ] > temp; j -= gap) {
                    array[ j ] = array[ j - gap ];
               }
               array[ j ] = temp;
          }
     }
}
Source by algostructure.com #
 
PREVIOUS NEXT
Tagged: #shell #sort #visualization
ADD COMMENT
Topic
Name
4+1 =