> For the complete documentation index, see [llms.txt](https://emory.gitbook.io/dsa-java/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://emory.gitbook.io/dsa-java/disjoint-sets/exercises.md).

# 6.3. Quiz

## Implementation

* Create the [`DisjointSetQuiz`](https://github.com/emory-courses/dsa-java/blob/master/src/main/java/edu/emory/cs/set/DisjointSetQuiz.java) class under the [`set`](https://github.com/emory-courses/dsa-java/blob/master/src/main/java/edu/emory/cs/set) package.
* Assume that the [`find()`](https://github.com/emory-courses/dsa-java/blob/master/src/main/java/edu/emory/cs/set/DisjointSet.java#L39) method in the `DisjointSet` class uses the baseline approach:

  ```java
  public int find(int id) {
      return (subsets[id] < 0) ? id : find(subsets[id]);
  }
  ```
* A disjoint set can be represented by a tree.  Update the [`main()`](https://github.com/emory-courses/dsa-java/blob/master/src/main/java/edu/emory/cs/set/DisjointSetQuiz.java#L20) method in the `DisjointSetQuiz` class that would result the following tree:

![](/files/-MK__JAi_SAtabbeTlG_)

## Report

Write a report `quiz6.pdf` that includes the followings:

* Describe how the values in the [`subsets[]`](https://github.com/emory-courses/dsa-java/blob/master/src/main/java/edu/emory/cs/set/DisjointSet.java#L24) array changes after each call in the `main()` method.
* Describe how the values in the [`subsets[]`](https://github.com/emory-courses/dsa-java/blob/master/src/main/java/edu/emory/cs/set/DisjointSet.java#L24) array would change after calling `find(0)` once all keys are added as above, assuming that the `find()` method in `DisjointSet` class uses the efficient approach:

  ```java
  public int find(int id) {
      return (subsets[id] < 0) ? id : (subsets[id] = find(subsets[id]));
  }
  ```
