49 add union find data structure#62
Conversation
…tor implementation
…concerns and notes in a comment
…t for subsets to HashMap
… mismatches that will be sorted out later on if I decide to stick with HashMaps
…by size in UnsortedUnionFind
…w private method contains(T e)
…ure maps fulfil set requirement
…) as static method problematic due to variable type
…ionFind; adapt interfaces accordingly
…by size in SortedUnionFindTest
… they are not helpful
…trings() in SortedUnionFindTest
|
TODO (WIP): make a concrete list of all things that we expect this PR to have with some examples (e.g. some interesting test-cases). Smaller work-packages are preferred. List of wants and goals for this MRUnion-Find commonly only defines two methods:
Another method We should discuss whether we want size method(s), e.g. for the amount of sets or elements in all sets. Sometimes a Interfaces (or abstract classes)
Implementations
Union-Find data-structures are usually based on trees and can be implemented using commonly existing implementations (e.g. our It makes sense to start with a "simple" implementation first, e.g. based on our
Ordered parent-pointer-tree implementations seem to require a proper merge of the trees in most cases. It makes sense to focus on the unordered variants first. TODO: investigate further. Note: a "unordered" data-structure implementation can sometimes be derived from an ordered. An example of this is our Tests
I advice to "extend" tests only by the new features introduced in each implementation, and re-use existing tests as far as possible. E.g. ordered Union-Find test classes can just extend their unordered test-classes. DocumentationTODO (Runtime) Optimization
Our goal is to use at least one Space complexity is usually O(n) and does not need to be optimized. EvaluationTODO |
…mpleBenchmarkTest; currently causes stack overflow even for small values
… amount of time; only for small values though; next step: replace recursion with iterative approach
…Test; the maths still needs sorting out though
…ionFind test suite due to time and memory constraints
So far, this includes the interfaces UnionFind, SortedUnionFind, PersistentUnionFind and PersistentSortedUnionFind as well as the abstract classes AbstractImmutableUnionFind and AbstractImmutableSortedUnionFind. It also contains a naive implementation of SortedUnionFind based on a HashMap of TreeSets (SortedTreeSetUnionFind). There is a set of tests (SortedUnionFindTest), but there seems to be some kind of problem regarding null values which is causing the JDK21 PackageSanityTest to fail. This in particular is something I'd appreciate input on. Thanks!