You are looking for the expected running time: expected value of T(n). So let T(n) be the random variable for running time. There are n possible outcomes each of which corresponds to a partition:
T(0) + T(n-1) + c
T(1) + T(n-2) + c
...
T(n-1) + T(0) + c
One of these is going to be picked, let X(i) = 1 if T(i) + T(n - i - 1) + c is picked and 0 otherwise. The recurrence for T(n) can then be written as:
T(n) = X(0)(T(0) + T(n-1) + c) + ... + X(n-1)(T(n-1) + T(0) + c)
Now to calculate the expectation, we write:
E( T(n) ) = E( X(0)(T(0) + T(n-1) + c) + ... + X(n-1)(T(n-1) + T(0) + c) )
= (1/n)E(2T(0) + 2T(1) + ... + 2T(n-1) + cn)
= (2/n)(E((T(0)) + ... + E(T(n-1))) + c.
Third line was obtained by linearity of expectation. At this point we are going to guess the answer for E( T(i) ) and use induction to prove it. This technique is called substitution.
- Guess:
E( T(i) ) <= Ai, for A > 0 and 1 <= i < n.
- Base: for i = 1, array is already sorted so expected running time is constant.
- Induction:
E( T(n) ) <= (2A/n)(n(n-1)/2) = A(n-1) <= An.
So claim holds for n. The expected running time is O(n).