Shell-sort algorithm complexity I tried to implement the shell-sort algorithm using this Java code:

// Using Pratt sequence 
public static void hSort(int tab[]) {
    int N = tab.length;    
    int k = 0;    
    int sequence = 1;

    // Getting the final term of the pratt sequence 
    while(((int)(Math.pow(3, k) - 1) / 2) &lt; N/3) {
        sequence = (int)(Math.pow(3, k) - 1) / 2;
        k++;
    }     
    k--;

    while(sequence &gt; 0) {
        hInsertionSort(tab, sequence);
        k--;
        sequence = (int)(Math.pow(3, k) - 1) / 2;
    }
}

// H sorting using insertion sort 
public static void hInsertionSort(int[] tab, int h) {
    int N = tab.length;
    int k = 0;
    while (k &lt; h) {
        for (int i = k; i &lt; N; i+=h) {
            for (int j = i; j &gt; k+h-1; j-=h) {
                if (less(tab[j], tab[j-h]) == -1) exch(tab, j, j-h);
                else break;
            }
        }
    k++;
    }
}


You can use the hsort method to try sort a table of integers.

Is the complexity of this implementation the same as the usual implementation?
Yes.
It is the same complexity.