-1

Hello I am taking Introduction to algorithm class this semeseter. However I have some problem in calculating time complexity of median of medians algorithm (here). I'm wondering how to get T(n)<=10cn from T(n)<=T(0.2n)+T(0.7n)+cn..

I think I cannot apply mater theorem to the expression above and wikipedia says I should use induction but I don't know How..

Community
  • 1
  • 1
Jiseop Han
  • 37
  • 5

1 Answers1

0

It is using induction. Assume for less than or equal n we have T(n) <= 10*c*n (we know the base of induction is true for equal or less than T(10) as they are constant and we can use large enough value for c). Now we want to prove this for T(n + 1). We know T(n + 1) <= T(0.2(n + 1)) + T(0.7( n + 1)) + c(n+1). From the assumption of the induction as 0.2(n + 1) and 0.7(n+1) is less than n (for n > 10), T(0.2(n + 1)) <= 10*c*0.2(n + 1) and T(0.7(n + 1)) <= 10*c*0.7(n + 1). Therefore, T(n+1) <= 2*c(n+1) + 7*c(n+1) + n*c = 10*c*n. The proof is completed!

OmG
  • 15,398
  • 7
  • 42
  • 71
  • would you please explain me the induction way? – Jiseop Han Oct 15 '18 at 08:25
  • @JiseopHan The answer is updated. If it works for you, please accept it as a solution. – OmG Oct 15 '18 at 08:28
  • I think there is calculation error in the equation above for akra-bazzi. T(x) = O(x * (1 + integral_1^{x}(x/x^2)=T(x) = O(x * (1 + integral_1^{x}(1/x)=O(x*(1+c*logx))=O(xlogx) isn't it? – Jiseop Han Oct 15 '18 at 08:56