EVENBAO's blog

By EVENBAO, history, 2 years ago, In English

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!

  • Vote: I like it
  • +8
  • Vote: I do not like it

»
2 years ago, # |
  Vote: I like it 0 Vote: I do not like it

Auto comment: topic has been updated by EVENBAO (previous revision, new revision, compare).

»
2 years ago, # |
  Vote: I like it +17 Vote: I do not like it

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.

  • »
    »
    2 years ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    Thanks for your help! well , I think I asked a dumb question lol.