Блог пользователя EVENBAO

Автор EVENBAO, история, 3 года назад, По-английски

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!

  • Проголосовать: нравится
  • +8
  • Проголосовать: не нравится

»
3 года назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

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

»
3 года назад, # |
  Проголосовать: нравится +17 Проголосовать: не нравится

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.