Hello everyone.
I just noticed that CF1648E has an easier approach , using Boruvka's algorithm.
Can anyone prove that the run time of this algorithm is O(ElogV)?
Thanks for reading!
# | 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 |
Hello everyone.
I just noticed that CF1648E has an easier approach , using Boruvka's algorithm.
Can anyone prove that the run time of this algorithm is O(ElogV)?
Thanks for reading!
Name |
---|
Auto comment: topic has been updated by EVENBAO (previous revision, new revision, compare).
I think the algorithm is somewhat self-explanatory about the log factor. But if it's not, then here is my explanation.
The log factor in the algorithm is the number of iteration. TL;DR: the number of components reduced by at least two after each iteration, hence the number of iterations.
Let's see the best case and the worse case. Let $$$opt(u)$$$ be the component that the optimal edge of the component $$$u$$$ connect to. This value act like a link, so for convenience, let's use that name. Now we find the number $$$cnt$$$, which is the of component $$$u$$$ such that $$$opt(opt(u)) \ne u$$$, that is, the component that $$$u$$$ is linking to is not link to $$$v$$$. In the optimal case, $$$cnt = 2$$$, meaning only two such components, so the links effectively form a tree. Therefore, in the best case, the number of iteration is $$$1$$$. The worse case is the reverse, $$$cnt \approx n$$$, meaning each new component will consist of two old components. But that is the point, in the worst case, the number of component is reduced by two, therefore we need about $$$\log n$$$ iterations.
Thanks for your help! well , I think I asked a dumb question lol.