Question: Implement a SubsetGenerator that generates all subsets of the characters of a string. For example, the subsets of the characters of the string rum are
Implement a SubsetGenerator that generates all subsets of the characters of a string. For example, the subsets of the characters of the string "rum" are the eight strings "rum", "ru", "rm", "r", "um", "u", "m", "" Note that the subsets don't have to be substringsfor example, "rm" isn't a substring of "rum".
You need to supply the following class in your solution:
SubsetGenerator
Use the following class as your tester class:
import java.util.Collections; import java.util.ArrayList; /** This program tests the subset generator. */ public class SubsetGeneratorTester { public static void main(String[] args) { SubsetGenerator generator = new SubsetGenerator("rum"); ArrayList subsets = generator.getSubsets(); // Sort the result for checking Collections.sort(subsets); System.out.println(subsets); System.out.println("Expected: [, m, r, rm, ru, rum, u, um]"); } } Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
