Kotlinlearncs.online LogoJava
Return to List

Test Writing: Equal Subsets

Created By: Chris Taylor
/ Version: 2023.7.0

Write the recursive method, equalSubsets(int[] nums, int start, int total1, int total2), that, when called by the provided equalSubsets(int[] nums) method, returns true if it is possible to partition the values in nums into two subgroups whose sum of values are equal. You may assume that nums is not null.

Test Design Challenge

You're challenge is to write tests for this problem described above.

  • Provide a method named test that accepts no arguments and does not return a value.
  • If the implementation of the class described above is incorrect, your test method should throw an exception.
  • If it is correct, do not throw an exception.
  • You may want to use Java's assert method
private boolean equalSubsets(int[] nums, int start, int total1, int total2) {
return false; // You may need to remove this starter code
}
boolean equalSubsets(int[] nums, int total) {
return equalSubsets(nums, 0, 0, 0);
}