MCPcopy Create free account
hub / github.com/Tiwarishashwat/InterviewCodes / find

Method find

CountTheNumberOfCompleteComponents.java:42–48  ·  view source on GitHub ↗
(int node)

Source from the content-addressed store, hash-verified

40
41 // Find root of component with path compression
42 int find(int node) {
43 if (parent[node] == node) {
44 return node;
45 }
46 parent[node] = find(parent[node]);
47 return parent[node];
48 }
49
50 void union(int node1, int node2) {
51 int rootParent1 = find(node1);

Callers 2

unionMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected