Возможно, это может помочь:
/**********************************************************************
* Complexity:
* This algorithm makes exactly one comparison on each step.
* On each step - algorithm divide initial array of size n :
* on 3 arrays with (2*n / 3) sizes
* N
* / | \
* 2N/3 2N/3 2N/3
* /
* (2N/3)2/3
* /
* ...
* /
* N * (2/3)^k = 1
* By considering this tree we can find the depth - k:
* N * (2/3)^k = 1 =>>
* N = 1 / (2/3)^k =>>
* N = (3/2)^k =>>
* log(3/2, N) = log(3/2, (3/2)^k) =>>
* k = log(3/2, N) (!!!)
*
* On each step algorithm makes 3^k comparisons =>> on the last step we will get:
* 3^(log(3/2, N)) =>> N^(log(3/2, 3))
* comparisons.
*
* We can compute the full work:
* 1 + 3 + 9 + ... + 3^(log(3/2, N))
* by using geometric progression formulas.
*
*************************************************************************/
public static void sort(Comparable[] a, int lo, int hi) {
if (lo >= hi) return;
if (less(a[hi], a[lo])) exch(a, hi, lo);
if (hi - lo + 1 > 2) {
int t = (hi - lo + 1) / 3;
sort(a, lo, hi - t);
sort(a, lo + t, hi);
sort(a, lo, hi - t);
}
}