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/d3/dae/dsu__path__compression_8cpp_source.html below:

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

Go to the documentation of this file. 46 explicit dsu

(uint64_t n) {

49 for

(uint64_t i = 0; i < n; i++) {

56 for

(uint64_t i = 0; i < n; i++) {

63 for

(uint64_t i = 0; i < n; i++) {

136

vector<uint64_t>

get

(uint64_t i) {

137

vector<uint64_t> ans;

140

ans.push_back(

size

(i));

177

vector<uint64_t> ans = {1, 4, 3};

178 for

(uint64_t i = 0; i < ans.size(); i++) {

179

assert(d.

get

(4).at(i) == ans[i]);

181

cout <<

"1st test passed!"

<<

endl

;

195

vector<uint64_t> ans = {3, 7, 4};

196 for

(uint64_t i = 0; i < ans.size(); i++) {

197

assert(d.

get

(3).at(i) == ans[i]);

199

cout <<

"2nd test passed!"

<<

endl

;

Disjoint sets union data structure, class based representation.

vector< uint64_t > get(uint64_t i)

prints the minimum, maximum and size of the set to which i belongs to

dsu(uint64_t n)

contructor for initialising all data members.

uint64_t findSet(uint64_t i)

Method to find the representative of the set to which i belongs to, T(n) = O(1)

uint64_t size(uint64_t i)

A utility function that returns the size of the set to which i belongs to.

vector< uint64_t > minElement

minimum of each set to which i belongs to

vector< uint64_t > p

keeps track of the parent of ith element

vector< uint64_t > maxElement

maximum of each set to which i belongs to

vector< uint64_t > depth

tracks the depth(rank) of i in the tree

bool isSame(uint64_t i, uint64_t j)

A utility function which check whether i and j belongs to same set or not.

uint64_t get_max(uint64_t i)

A utility function that returns the max element of the set to which i belongs to.

void UnionSet(uint64_t i, uint64_t j)

Method that combines two disjoint sets to which i and j belongs to and make a single set having a com...

vector< uint64_t > setSize

size of each chunk(set)

uint64_t get_min(uint64_t i)

A utility function that returns the min element of the set to which i belongs to.

static void test2()

Self-implementations, 2nd test.

int main()

Main function.

static void test1()

Self-test implementations, 1st test.


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