
I have to implement a SubstringGenerator (class) that generates all substrings of a string recursively. 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'
Substrings of "abc123"
Actual: '' '3' '2' '23' '1' '12' '123' 'c' 'c1' 'c12' 'c123' 'b' 'bc' 'bc1' 'bc12' 'bc123' 'a' 'ab' 'abc' 'abc1' 'abc12' 'abc123'
Expected: '' '3' '2' '23' '1' '12' '123' 'c' 'c1' 'c12' 'c123' 'b' 'bc' 'bc1' 'bc12' 'bc123' 'a' 'ab' 'abc' 'abc1' 'abc12' 'abc123'.
Recursion is really confusing to me and I'm not super sure where to start. I know I need a base case (which i assume would be something to do with the length of the string?), but I don't know where to go from here. Can you help?
The problem is from Big Java 6th edition Chapter 13. Excersice 13.14

Trending nowThis is a popular solution!
Step by stepSolved in 3 steps with 6 images

- I just need the method they are asking for Write a recursive function that takes a start index, array of integers, and a target sum. Your goal is to find whether a subset of the array of integers adds up to the target sum. The start index is initially 0.A target sum of 0 is true for any array. Examples: subsetSum(0, {2, 4, 8}, 10) -> true public boolean subsetSum(int start, int[] nums, int target) { }arrow_forwardPlease complete the task by yourself only in JAVA with explanation. Don't copy. Thank you. Using quicksort to sort an array of car objects by various criteria. Define a class Car as follows: class Car { public String make; public String model; public int mpg; // Miles per gallon } b) Implement a comparator called CompareCarsByDescendingMPG that can be passed as an argument to the quicksort method from the lecture notes. CompareCarsByDescendingMPG should return a value that will cause quicksort to sort an array of cars in descending order (from largest to smallest) by mpg.arrow_forwarduse The C Programming Language Online Compile for Recamán's Sequence Implement this in a program. Write two functions, one for solving it iteratively, one for solving it recursively. Take two arguments from the command-line: an "i" or "r", and the term number (how many terms to print). Print out which method executed (was selected) and all the terms (and the number of terms).arrow_forward
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education





