Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

What are the common operations of C++ and checking collections?

Shulou Source: shulou.com Published: 2022-05-31 13:54:00 10月03日 Update

This article mainly introduces the relevant knowledge of the common operation of C++ and search collection, the content is detailed and easy to understand, the operation is simple and fast, and has a certain reference value. I believe that after reading this C++ and searching the common operation of what articles will have a harvest, let's take a look.

Preface

The parallel lookup set is a kind of multi-tree, which is used to deal with the merge and query of disjoint sets.

Popular understanding: in daily life, we will give accommodation and favouritism because someone is our own friend, even if a friend of a friend has a friend. The basic concept of parallel search set is to judge whether two sets are "friends" and make the two sets "friends".

Common operation

Initialization: each node acts as a separate collection

Query: find the representative element of the collection in which the element is located, that is, the root node

Merge: merge the collection of two elements into one collection

Before merging, you should first judge whether two elements belong to the same set, and use the "query" above to implement

Algorithm realization

Initialization: initially, each node is a collection, and father [I] represents the parent node of node I. if father [I] = I, we think this node is the root node of the current collection (at the beginning, the root node of each node is himself).

Void init () {for (int I = 1; I)

Tags: Node Node query Common two element friend Category location knowledge complexity content complexity namely case time article structure path Recursion Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno NVidia macOS Redmi Shulou Information Shulou Technology