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??










share|improve this question
























  • n=5^k; k = log(n) base5; the GP will run long(n) base5 times.
    – roottraveller
    Jul 15 '17 at 16:02















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??










share|improve this question
























  • n=5^k; k = log(n) base5; the GP will run long(n) base5 times.
    – roottraveller
    Jul 15 '17 at 16:02













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??










share|improve this question















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






share|improve this question















share|improve this question













share|improve this question




share|improve this question








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


















  • 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












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)).






share|improve this answer























    Your Answer






    StackExchange.ifUsing("editor", function () {
    StackExchange.using("externalEditor", function () {
    StackExchange.using("snippets", function () {
    StackExchange.snippets.init();
    });
    });
    }, "code-snippets");

    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "1"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














     

    draft saved


    draft discarded


















    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
































    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)).






    share|improve this answer



























      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)).






      share|improve this answer

























        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)).






        share|improve this answer














        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)).







        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited Jul 16 '17 at 11:05

























        answered Jan 25 '17 at 20:05









        David Eisenstat

        36.4k73372




        36.4k73372






























             

            draft saved


            draft discarded



















































             


            draft saved


            draft discarded














            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




















































































            這個網誌中的熱門文章

            Academy of Television Arts & Sciences

            L'Équipe

            1995 France bombings