javadata-structurescollectionsdisjoint-setsunion-find

Is the disjoint-set data structure implemented natively in Java?


I searched for a native implementation of the disjoint-set data structure in Java. But I didn't find one, only in external libraries.

Did I miss it or does it actually not exist?


Solution

  • If there was an implementation of the disjoint-set data structure, it would likely be located in the java.util package. Sets are included, but not disjoint-sets: https://docs.oracle.com/javase/8/docs/api/java/util/package-summary.html.

    The closest I found was the disjoint method in the java.util.collections class: https://docs.oracle.com/en/java/javase/13/docs/api/java.base/java/util/Collections.html#disjoint%28java.util.Collection,java.util.Collection%29