How to solve equation T(n) = 5T(n/5) + sqrt(n), T(1) = 1, T(0) = 0 using recursion tree?
up vote
0
down vote
favorite
When I apply master theorem, I get O(n) but when I try to solve it using recursion tree, I get stuck and couldn't make out any solution.
I tried this :
T(n) = 5T(n/5) + sqrt(n)
T(n) = 5(5T(n/25) + sqrt(n/5)) + sqrt(n)
= 25T(n/25) + sqrt(5n) + sqrt(n)
T(n) = 5(5(5T(n/125) + sqrt(n/25)) + sqrt(n/5)) + sqrt(n)
= 125T(n/25) + sqrt(25) + sqrt(5n) + sqrt(n)
.
.
.
T(n) = sqrt(n) + sqrt(5n) + sqrt(25n) + sqrt(125n) + sqrt(625n) + sqrt(3125n) + ...
How do I suppose to solve this GP??
algorithm recursion time-complexity master-theorem
add a comment |
up vote
0
down vote
favorite
When I apply master theorem, I get O(n) but when I try to solve it using recursion tree, I get stuck and couldn't make out any solution.
I tried this :
T(n) = 5T(n/5) + sqrt(n)
T(n) = 5(5T(n/25) + sqrt(n/5)) + sqrt(n)
= 25T(n/25) + sqrt(5n) + sqrt(n)
T(n) = 5(5(5T(n/125) + sqrt(n/25)) + sqrt(n/5)) + sqrt(n)
= 125T(n/25) + sqrt(25) + sqrt(5n) + sqrt(n)
.
.
.
T(n) = sqrt(n) + sqrt(5n) + sqrt(25n) + sqrt(125n) + sqrt(625n) + sqrt(3125n) + ...
How do I suppose to solve this GP??
algorithm recursion time-complexity master-theorem
n=5^k; k = log(n) base5; the GP will run long(n) base5 times.
– roottraveller
Jul 15 '17 at 16:02
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
When I apply master theorem, I get O(n) but when I try to solve it using recursion tree, I get stuck and couldn't make out any solution.
I tried this :
T(n) = 5T(n/5) + sqrt(n)
T(n) = 5(5T(n/25) + sqrt(n/5)) + sqrt(n)
= 25T(n/25) + sqrt(5n) + sqrt(n)
T(n) = 5(5(5T(n/125) + sqrt(n/25)) + sqrt(n/5)) + sqrt(n)
= 125T(n/25) + sqrt(25) + sqrt(5n) + sqrt(n)
.
.
.
T(n) = sqrt(n) + sqrt(5n) + sqrt(25n) + sqrt(125n) + sqrt(625n) + sqrt(3125n) + ...
How do I suppose to solve this GP??
algorithm recursion time-complexity master-theorem
When I apply master theorem, I get O(n) but when I try to solve it using recursion tree, I get stuck and couldn't make out any solution.
I tried this :
T(n) = 5T(n/5) + sqrt(n)
T(n) = 5(5T(n/25) + sqrt(n/5)) + sqrt(n)
= 25T(n/25) + sqrt(5n) + sqrt(n)
T(n) = 5(5(5T(n/125) + sqrt(n/25)) + sqrt(n/5)) + sqrt(n)
= 125T(n/25) + sqrt(25) + sqrt(5n) + sqrt(n)
.
.
.
T(n) = sqrt(n) + sqrt(5n) + sqrt(25n) + sqrt(125n) + sqrt(625n) + sqrt(3125n) + ...
How do I suppose to solve this GP??
algorithm recursion time-complexity master-theorem
algorithm recursion time-complexity master-theorem
edited Jan 26 '17 at 8:28
asked Jan 25 '17 at 19:43
dj_1993
445
445
n=5^k; k = log(n) base5; the GP will run long(n) base5 times.
– roottraveller
Jul 15 '17 at 16:02
add a comment |
n=5^k; k = log(n) base5; the GP will run long(n) base5 times.
– roottraveller
Jul 15 '17 at 16:02
n=5^k; k = log(n) base5; the GP will run long(n) base5 times.– roottraveller
Jul 15 '17 at 16:02
n=5^k; k = log(n) base5; the GP will run long(n) base5 times.– roottraveller
Jul 15 '17 at 16:02
add a comment |
1 Answer
1
active
oldest
votes
up vote
1
down vote
The final sum has log_5(n) + O(1) terms, since the recursion bottoms out. The largest is sqrt(5^(log_5(n) + O(1)) n) = sqrt(O(n) n) = O(n). The others decrease geometrically, so they don't matter in the big-O accounting (alternatively, divide through by 1 + sqrt(1/5) + sqrt(1/5^2) + ... = Theta(1)).
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
1
down vote
The final sum has log_5(n) + O(1) terms, since the recursion bottoms out. The largest is sqrt(5^(log_5(n) + O(1)) n) = sqrt(O(n) n) = O(n). The others decrease geometrically, so they don't matter in the big-O accounting (alternatively, divide through by 1 + sqrt(1/5) + sqrt(1/5^2) + ... = Theta(1)).
add a comment |
up vote
1
down vote
The final sum has log_5(n) + O(1) terms, since the recursion bottoms out. The largest is sqrt(5^(log_5(n) + O(1)) n) = sqrt(O(n) n) = O(n). The others decrease geometrically, so they don't matter in the big-O accounting (alternatively, divide through by 1 + sqrt(1/5) + sqrt(1/5^2) + ... = Theta(1)).
add a comment |
up vote
1
down vote
up vote
1
down vote
The final sum has log_5(n) + O(1) terms, since the recursion bottoms out. The largest is sqrt(5^(log_5(n) + O(1)) n) = sqrt(O(n) n) = O(n). The others decrease geometrically, so they don't matter in the big-O accounting (alternatively, divide through by 1 + sqrt(1/5) + sqrt(1/5^2) + ... = Theta(1)).
The final sum has log_5(n) + O(1) terms, since the recursion bottoms out. The largest is sqrt(5^(log_5(n) + O(1)) n) = sqrt(O(n) n) = O(n). The others decrease geometrically, so they don't matter in the big-O accounting (alternatively, divide through by 1 + sqrt(1/5) + sqrt(1/5^2) + ... = Theta(1)).
edited Jul 16 '17 at 11:05
answered Jan 25 '17 at 20:05
David Eisenstat
36.4k73372
36.4k73372
add a comment |
add a comment |
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f41860287%2fhow-to-solve-equation-tn-5tn-5-sqrtn-t1-1-t0-0-using-recursi%23new-answer', 'question_page');
}
);
Post as a guest
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
n=5^k; k = log(n) base5; the GP will run long(n) base5 times.– roottraveller
Jul 15 '17 at 16:02