code: @Override
      public int find(int x) {
          int curr = x;
          int currp = p[curr];
          while (curr != currp) {
              curr = currp;
              currp = p[curr];
          }
          int ancestor = curr;
          curr = x;
          while (curr != ancestor) {
              int next = p[curr];
              p[curr] = ancestor;
              curr = next;
          }
  
          return ancestor;
      }
docs: Finds the set of a given element, and compresses the path to the root node.
  
  @param x
  the element
  
  @return the identifier of the set which contains the given element