Path compression upon union in DSU

Правка en1, от bloodoath, 2022-08-17 11:12:07

Given, two disjoint sets with roots 1 and 6 respectively which already have their childrens' paths compressed.

I wish to do a union but instead of

this

I want

this

Unable to figure out a way to do this optimally.

DSU I am using is on cp-algorithms

Теги dsu

История

 
 
 
 
Правки
 
 
  Rev. Язык Кто Когда Δ Комментарий
en1 Английский bloodoath 2022-08-17 11:12:07 583 Initial revision (published)