[PTA] ADS-2016 Assignment 6 2-4

        Which one of the following is the lowest upper bound of T(n).T(n) for the following recursion T(n)=2T(n)+logn?(4分)

        [PTA] ADS-2016 Assignment 6 2-4_第1张图片


        设 m = logn, 则2^m = n.

        T(2^m) = 2T(2^(m/2))) + m

        设 G(m) = T(2^m),则原式转化为G(m) = 2G(m/2) + m

        根据主定理,a = 2, b = 2, k = 1, p = 0. a = b^k,满足条件2,所以算法复杂度为O(mlogm)

        又因为 m = logn,所以算法复杂度为O(logn loglogn )


附:主定理

        [PTA] ADS-2016 Assignment 6 2-4_第2张图片

你可能感兴趣的:([PTA] ADS-2016 Assignment 6 2-4)