I have seen lot of DSU solutions for a problem that implements DSU as shown below.

```
class Dsu {
private int parent[];
public Dsu(int N) {
parent = new int[N];
for (int i = 0; i < N; i++) {
parent[i] = i;
}
}
int find(int u) {
if (parent[u] != u) return parent[u] = find(parent[u]);
return parent[u];
}
int union(int u, int v) {
return parent[find(u)] = find(v);
}
}
```

I am not able to understand how the time complexity of find() and union() operation is O(1).

Kindly provide explanation with proof that time complexity would be constant, some learning resources on this would be very useful.