Class SubsetsGivenSumTest

java.lang.Object
topics.backtracking.subsetsum.SubsetsGivenSumTest

class SubsetsGivenSumTest extends Object

Test Suite for SubsetsGivenSum

Validates the exhaustive backtracking algorithm used to resolve the Subset Sum problem. Employs assertions to verify combinatorial subset generation against predefined integer arrays and expected sums.

Author:
vicegd
  • Constructor Details

    • SubsetsGivenSumTest

      SubsetsGivenSumTest()
  • Method Details

    • setup

      @BeforeAll public static void setup()
      Initializes context and resources prior to executing the test suite.
    • teardown

      @AfterAll public static void teardown()
      Cleans up resources after the entire test suite has finished execution.
    • shouldFindThreeSubsetsSummingToTenUsingNaturalNumbers

      @Test public void shouldFindThreeSubsetsSummingToTenUsingNaturalNumbers()

      Scenario: A set consisting of the first 5 natural numbers {1, 2, 3, 4, 5}.

      Expected Outcome: The algorithm must locate exactly 3 subsets that total 10 (e.g., {1, 4, 5}, {2, 3, 5}, {1, 2, 3, 4}).

    • shouldFindOneSubsetSummingToFourteenUsingPerfectSquares

      @Test public void shouldFindOneSubsetSummingToFourteenUsingPerfectSquares()

      Scenario: A set consisting of the first 4 perfect squares {1, 4, 9, 16}.

      Expected Outcome: The algorithm must locate exactly 1 subset that totals 14 (e.g., {1, 4, 9}).