Can somebody help me in finding running time of algo: Partitions the problem into two sub-problems of sizes n/5 and 7n/10, and spends O(n/log n) time to divide and combine the solutions.
# | User | Rating |
---|---|---|
1 | tourist | 3985 |
2 | jiangly | 3814 |
3 | jqdai0815 | 3682 |
4 | Benq | 3529 |
5 | orzdevinwang | 3526 |
6 | ksun48 | 3517 |
7 | Radewoosh | 3410 |
8 | hos.lyric | 3399 |
9 | ecnerwala | 3392 |
9 | Um_nik | 3392 |
# | User | Contrib. |
---|---|---|
1 | cry | 169 |
2 | maomao90 | 162 |
2 | Um_nik | 162 |
4 | atcoder_official | 161 |
5 | djm03178 | 158 |
6 | -is-this-fft- | 157 |
7 | adamant | 155 |
8 | awoo | 154 |
8 | Dominater069 | 154 |
10 | luogu_official | 150 |
Can somebody help me in finding running time of algo: Partitions the problem into two sub-problems of sizes n/5 and 7n/10, and spends O(n/log n) time to divide and combine the solutions.
Name |
---|
We denote running time by T(n). Then
T(n)<=T(n/5)+T(7n/10)+an/log(n)
, where a is constant. Obviously, if running time of combining is asymptotically exactly O(n/log n), then T(n) cannot be less. So if we want to prove that T(n)=O(n/log n), then it is sufficient to prove that for some constant c:T(n)<=cn/log n
. Let's try to do this by induction.We can prove the base of induction for arbitrary large N: if we pick c big enough, we will have
T(n)<=cn/log n
for all n <= N. So the most interesting part is step. Here we haveWe see that
log(n/5)=log(n)-log(5)
, and so the first summand in the brackets tends to 1/5 when n tends to infinity; similarly, the second summand tends to 7/10. So we can choose N in such a way that for n>=N first summand is not greater than, say, 1/5+1/100, and second is not greater than 7/10+1/100. Then we can choose c big enough to prove induction base for n<=N and to make a/c less than 1/10-2/100. Therefore we obtain that the expression in brackets is not greater than 1, so we proved the induction step (we used the induction assumption for n/5 and 7n/10). The answer isO(n/log n)
Use Latex to format equations, i.e. put the formulas inbetween dollar signs: