Let's substitute the following expressions into our equation :
T(n)=2T(n/2)+n−1⟶⎩⎨⎧n→n/2:T(n/2)=2T(n/4)+n/2−1n→n/4:T(n/4)=2T(n/8)+n/4−1n→n/8:T(n/8)=2T(n/16)+n/8−1
This will be enough to make a hypothesis.
Then,
T(n)=21⋅T(21n)+1⋅n−=201⟶T(n)=2⋅(2⋅T(4n)+n/2−1)+1⋅n−1==4⋅T(4n)+1⋅n−2+1⋅n−1⟶T(n)=22⋅T(22n)+2⋅n−(20+21)T(n)=4⋅(2⋅T(8n)+n/4−1)+2⋅n−(1+2)==8⋅T(8n)+n−4+2⋅n−(1+2)⟶T(n)=23⋅T(23n)+3⋅n−(20+21+22)T(n)=8⋅(2⋅T(16n)+n/8−1)+3⋅n−(20+21+22)==16⋅T(16n)+n−8+3⋅n−(20+21+22)⟶T(n)=24⋅T(24n)+4n−(20+21+22+23)
Then,
T(n)=2k⋅T(2kn)+nk−(20+21+22+…+2k−1)
It remains to calculate the sum in brackets, which is a geometric sum with the following parameters: a1=1 and r=2, then
20+21+22+…+2k−1=r−1a1⋅(rk−1)=2−12k−1⟶20+21+22+…+2k−1=2k−1
Conclusion,
T(n)=2k⋅T(2kn)+nk−(2k−1)
We use the initial condition :
2kn=1→n=2k→k=log2n
Then,
T(n)==n2log2n⋅T(1)+n⋅log2n−(=n2log2n−1)⟶T(n)=n⋅1+n⋅log2n−(n−1)⟶T(n)=n⋅log2n+1+O(n⋅log2n)
ANSWER
T(n)=2T(n/2)+n−1⟶T(n)=n⋅log2n+1+O(n⋅log2n)