Skip to content
This repository was archived by the owner on Sep 6, 2024. It is now read-only.

Union Find

Vasiliy Azarov edited this page Apr 23, 2021 · 2 revisions

For the solution, union-find with path compression and a counter are used, which is initialized with a value equal to the number of members of the social network. The counter is decremented after each merge. When all the elements are combined, the counter will have a value of 1.

The solution is weighted union-find with path compression and an array of the same size that contains the values of the maximum element. This value is assigned with path compression and union.

For the solution, union-find with path compression is used. When an element is deleted, it is combined with the next one (which, when the root of the given element is found, will give us a successor).

Clone this wiki locally