Question
I need this to be recursive Implement a SubstringGenerator (class) that generates all substrings of a string recursively. I looked at other answers but they
I need this to be recursive Implement a SubstringGenerator (class) that generates all substrings of a string recursively.
I looked at other answers but they didnt do it right.
For example, the substrings of the string rum are the seven strings
rum, ru, r, um, u, m,
Hint: First enumerate all substrings that start with the first character. There are n of them if the string has length n. Then enumerate the substrings of the string that you obtain by removing the first character.
Here is what your output should look like after your project is completed. (The order of your substrings is not important, if your generator produces all substrings correctly).
Substrings of "ab"
Actual: '' 'b' 'a' 'ab'
Expected: '' 'b' 'a' 'ab'
Substrings of "abc"
Actual: '' 'c' 'b' 'bc' 'a' 'ab' 'abc'
Expected: '' 'c' 'b' 'bc' 'a' 'ab' 'abc'
import java.util.ArrayList; /** * This class generates substrings of a string. */ public class SubstringGenerator { public static ArrayList
This is the tester class
import java.util.ArrayList; public class SubstringTester { public static void main(String[] args) { ArrayList
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started