(x)
| 20 | } |
| 21 | |
| 22 | findSet(x) { |
| 23 | // Function to find the set x belongs to (with path-compression) |
| 24 | if (this.map[x] !== this.map[x].parent) { |
| 25 | this.map[x].parent = this.findSet(this.map[x].parent.key) |
| 26 | } |
| 27 | return this.map[x].parent |
| 28 | } |
| 29 | |
| 30 | union(x, y) { |
| 31 | // Function to merge 2 disjoint sets |
no outgoing calls
no test coverage detected