Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

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

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)05/31 Report--

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)

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report