Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
478 views
in Technique[技术] by (71.8m points)

recursion - T(n) = c1T(n/a) + c2(T/b) + f(n)

Example T(n)=T(n/3)+T(n/4)+3n is this solvable with iterative master theorem or recursion tree.Can someone solve it analytically to show how it's done ?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

We can expand T(n) with a binomial summation:

enter image description here

(after some steps - can be proven by induction

enter image description here

For some depth of expansion / recursion k.

Where do we terminate? When the parameters to all instances of f(n) reach a certain threshold C. Thus the maximum depth of expansion:

enter image description here

We choose the smallest between a, b because the parameter with only powers of min(a, b) decreases at the slowest rate:

enter image description here

Thus the general expression for T(n) is:

enter image description here

The existence of a closed form analytical solution depends on the form of f(n). For the example provided:

enter image description here

The inner summation is the expansion of a binomial bracket raised to power j:

enter image description here

This is a geometric series, and equals (using standard formula):

enter image description here

Now since 7/12 is less than 1, the power term in the above result becomes vanishingly small for large values of k (and thus n). Therefore in the limit of large n:

enter image description here

Truth be told the above example could have been done more straightforwardly with a recursion tree; but the same does not go for e.g. other powers of n, e.g. f(n) = Cn^2, which can be trivially incorporated into the general formula.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...