问题
My friend and I have found this problem and we cannot figure out how to solve it. Its not trivial and standard substitution method does not really work(or we cannot apply it correctly) This should be quicksort with pivots at rank problem.
Here is the recurrence:
T(n) = T(n^(1/2)) + T(n-n^(1/2)) + n
Any help would be much appreciated. Thanks!
回答1:
First take it easy:
T(n) = T(n-n^(1/2)) + n, number of iteration is n^(1/2), in each iteration you'll have n-ksqrt(n) time complexity, so total time complexity is: ∑n-ksqrt(n) for 0<=k<=sqrt(n), which is n^(3/2).
Now solve your own problem:
T(n) = T(n^(1/2))+T(n-n^(1/2)) + n
again calculate number of steps till arriving to zero or 1: first part `T(n^(1/2)) takes O(log log n) time, and second part takes O(sqrt(n)) times to arriving to zero or 1 (See my answer to related question), So second part dominates first part, Also in each iteration time complexity of second part causes to sqrt(n) extra item, which doesn't effect to the first part time complexity (n-sqrt(n)), so your total runtime is n*sqrt(n).
来源:https://stackoverflow.com/questions/10544241/recurrence-relation-tn-tn1-2-tn-n1-2-n