= Solution
Use parallel <arrays> for keys and their representative values, with only a prefix active:
``
override val capacity: Int = 1000
private val elements = new Array[Int](capacity)
private val representatives = new Array[Int](capacity)
private var used = 0
``
The chosen bound is an explicit implementation parameter of the <abstract data type>; another a-priori positive bound works identically. \b[The initial map is empty because `used == 0`.] Zero-filled unused cells are not members of the map, so zero and negative keys remain valid <integers>. Use `DisjointSets` consistently as the trait name; the source's prose variation `DisjointSubsets` does not change the declared interface.
Back to article page