And lookup, path compression

Table of contents

And lookup

And find path compression


And lookup

Union-find sets: (union-find sets) is a simple set with a wide range of uses. Union-find sets are several disjoint sets, which can achieve faster merging and determine the operation of the set where the elements are located. There are many applications, such as finding none The number of connected components of the graph, the minimum common ancestor, job sorting with restrictions, and the most perfect application: implement the Kruskar algorithm to find the minimum spanning tree.

Literally, a collection that supports merge and find operations.
It is mainly used to judge the connectivity problem, that is, whether there is a road between two points in the graph that can be connected.
There are two basic operations for union search:

  1. Merge (Union/Merge): Merge two collections.
  2. Query (Find/Get): Query the collection to which the element belongs.
     

The concept of union check

In computer science, and check set (English: Disjoint-set data structure, literally translated as disjoint data structure ) is a

Guess you like

Origin blog.csdn.net/qq_38998213/article/details/132245604