问题
Given: T(n) = T(n/10) + T(an) + n
for some a
(which I know nothing about its value), and that: T(n) = 1
if n < 10
.
I want to check if the following is possible (for some a
values, and I want to find the smallest possible a
):
For every
c > 0
there isn0 > 0
such that for everyn > n0
,T(n) >= c * n
Or in other words T(n)=omega(n)
Any help is appreciated.
回答1:
Suppose that a < 9/10. Let c = max(1/(9/10 - a), 1), so that c ≥ 1 and 1/c ≤ 9/10 - a. Then for 1 ≤ n < 10,
T(n) = 1 ≤ n ≤ cn.
Inductively, for n ≥ 10,
T(n)
= T(n/10) + T(an) + n
≤ cn/10 + can + n
= c(1/10 + a + 1/c)n
≤ c(1/10 + a + 9/10 - a)n
= cn.
Now suppose that a = 9/10. For 1 ≤ n < 10, we know log10 n < 1 and therefore
T(n) = 1 > n log10 n - n.
Inductively, for n ≥ 10,
T(n)
= T(n/10) + T(9n/10) + n
> (n/10) log10 (n/10) - (n/10) + (9n/10) log10 (9n/10) - (9n/10) + n
= (n/10) log10 (n/10) + (9n/10) log10 (9n/10)
> (n/10) log10 (n/10) + (9n/10) log10 ( n/10)
= (n/10) (log10 n - 1) + (9n/10) (log10 n - 1)
= n log10 n - n.
Given c > 0, pick n0 such that log10 n0 - 1 = c, i.e., n0 = exp10(c + 1). Then for all n > n0,
T(n) > n log10 n - n = n(log10 n - 1) > n(log10 n0 - 1) = cn.
回答2:
For every c > 0 there is n0 > 0 such that for every n > n0, T(n) >= c*n
We assume T(n) >= cn holds for some a and every c > 0.
By substituting the recurrence in the inequality and solving for a, you will get:
T(n) >= c*n
(c*n/10) + (c*a*n) + n >= c*n
a >= (9/10) - (1/c)
Since our desired outcome is to hold for all c (formally apply limit c tends to infinity, which is where RHS will maximize), we get a >= (9/10). Therefore, smallest value of a
is (9/10) which will satisfy T(n) >= c*n
for all c.
After this, you can prove by induction, that this is indeed the case.
回答3:
In each function, you need to find the highest impacting variable of the equation. On the big scale, the smallest possible N affecting this function is any Constant.
来源:https://stackoverflow.com/questions/64721244/calculate-complexity-of-tn