A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://TheAlgorithms.github.io/C-Plus-Plus/de/d23/disjoint__set_8cpp_source.html below:

TheAlgorithms/C++: data_structures/disjoint_set.cpp Source File

Go to the documentation of this file. 29

vector<int> root, rank;

38

root = vector<int>(n + 1);

39

rank = vector<int>(n + 1, 1);

40 for

(

int

i = 1; i <= n; ++i) {

57 return

root[x] =

Find

(root[x]);

81 if

(rank[a] < rank[b]) {

83

}

else if

(rank[a] > rank[b]) {

97 for

(

int

i = 1; i <= 100; ++i) {

99

cout <<

"Fail"

<<

endl

;

104

cout <<

"1 and 2 are initially not in the same subset"

<<

endl

;

106

cout <<

"Fail"

<<

endl

;

109

cout <<

"1 and 2 are now in the same subset"

<<

endl

;

111

cout <<

"Fail"

<<

endl

;

bool InSameUnion(int x, int y)


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4