Disjoint-set (disjoint sets) operation Deunion

Additional operations disjoint-set (disjoint set) D e in n i O n Deunion , its function is to achieve undo the last The n i O n Union operation.

Realize ideas

Initialize an empty stack, each time The n i O n Union two root set of operations and the value P in s h Push stack; if performed D e in n i O n Deunion operation, the stack only needs to be P O p Pop can operate. Nopath compressiontime, this strategy is valid; if disjoint-set (disjoint set) to achieve apath compression, such that the D e in n i O n Deunion operation difficult, since thepath compressora great probability originally belonging to the elements under a root connected to the other root, if performed at this time The n i O n Union operation, it is difficult to recover.

Published 32 original articles · won praise 18 · views 3234

Guess you like

Origin blog.csdn.net/u011714517/article/details/104170113