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 | 4009 |
2 | jiangly | 3823 |
3 | Benq | 3738 |
4 | Radewoosh | 3633 |
5 | jqdai0815 | 3620 |
6 | orzdevinwang | 3529 |
7 | ecnerwala | 3446 |
8 | Um_nik | 3396 |
9 | ksun48 | 3390 |
10 | gamegame | 3386 |
# | User | Contrib. |
---|---|---|
1 | cry | 167 |
2 | Um_nik | 163 |
3 | maomao90 | 162 |
3 | atcoder_official | 162 |
5 | adamant | 159 |
6 | -is-this-fft- | 158 |
7 | awoo | 157 |
8 | TheScrasse | 154 |
9 | Dominater069 | 153 |
9 | nor | 153 |
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.