Rearrange the following lines of code to produce a recursive method that yields all ways in which a string can be broken up into substrings of arbitrary length. For example, the string bear can be broken up in the following ways
Rearrange the following lines of code to produce a recursive method that yields all ways in which a string can be broken up into substrings of arbitrary length. For example, the string bear can be broken up in the following ways
Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
Related questions
Question
![A learn.zybooks.com
b Membership | bartleby
zy Section 13.6 - CSC 1351: Computer Science
ibrary > CSC 1351: Computer Science Il for Majors home > 13.6: Permutations
E zyBooks catalog
PARTICIPATION
АСTIVITY
13.6.5: Produce a recursive method for creating substrings of arbitrary length.
Rearrange the following lines of code to produce a recursive method that yields all ways in which a string can be broken up into
substrings of arbitrary length. For example, the string bear can be broken up in the following ways:
bear
be ar
b ea r
b ear
be a r
be ar
bea r
bear
Mouse: Drag/drop
Keyboard: Grab/release Spacebar (or Enter). Move DOO Cancel Esc
Unused
Bear.java
Load default template.
String Tirst = str.substrıng(e, 1);
String rest = str.substring (i);
for (int i = 1; i< str.length(); i++)
import java.util.ArrayList;
public class Bear
public static ArrayList<String> breakups (String str)
if (str.length () > 1)
public static void main(String [] args)
ArrayList<String> result = new ArrayListo
for (Strings: shorter)
ArrayList<String> result = breakups("bear");
for (String element : result)
result.add(first + "" + s);
System.out.println(element);
return result;
result.add(str);
Check
Feedback?
MacBook Pro
esc
**
23
$
&
3
4
5
6
7
8
Q
W
E
R
Y
U
P
D
G
H
J
K
C
V
M
.. ..
V
B](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2Fdc88626a-4317-4667-9c61-42c19d7a8a1b%2F088d4531-199e-483d-8193-0c1c52c88590%2Fl22xflk_processed.jpeg&w=3840&q=75)
Transcribed Image Text:A learn.zybooks.com
b Membership | bartleby
zy Section 13.6 - CSC 1351: Computer Science
ibrary > CSC 1351: Computer Science Il for Majors home > 13.6: Permutations
E zyBooks catalog
PARTICIPATION
АСTIVITY
13.6.5: Produce a recursive method for creating substrings of arbitrary length.
Rearrange the following lines of code to produce a recursive method that yields all ways in which a string can be broken up into
substrings of arbitrary length. For example, the string bear can be broken up in the following ways:
bear
be ar
b ea r
b ear
be a r
be ar
bea r
bear
Mouse: Drag/drop
Keyboard: Grab/release Spacebar (or Enter). Move DOO Cancel Esc
Unused
Bear.java
Load default template.
String Tirst = str.substrıng(e, 1);
String rest = str.substring (i);
for (int i = 1; i< str.length(); i++)
import java.util.ArrayList;
public class Bear
public static ArrayList<String> breakups (String str)
if (str.length () > 1)
public static void main(String [] args)
ArrayList<String> result = new ArrayListo
for (Strings: shorter)
ArrayList<String> result = breakups("bear");
for (String element : result)
result.add(first + "" + s);
System.out.println(element);
return result;
result.add(str);
Check
Feedback?
MacBook Pro
esc
**
23
$
&
3
4
5
6
7
8
Q
W
E
R
Y
U
P
D
G
H
J
K
C
V
M
.. ..
V
B

Transcribed Image Text:A learn.zybooks.com
b Membership | bartleby
zy Section 13.6 - CSC 1351: Computer Science Il for
library > CSC 1351: Computer Science I| for Majors home > 13.6: Permutations
E zyBooks catalog
PARTICIPATION
ACTIVITY
13.6.5: Produce a recursive method for creating substrings of arbitrary length.
Rearrange the following lines of code to produce a recursive method that yields all ways in which a string can be broken up into
substrings of arbitrary length. For example, the string bear can be broken up in the following ways:
be ar
be ar
b ea r
b ear
be a r
be ar
bea r
bear
Mouse: Drag/drop
Keyboard: Grab/release Spacebar (or Enter). Move DCO Cancel Esc
Unused
Bear.java
Load default template..
----- -
ArrayList<String> shorter = breakups (rest);
import java.util.ArrayList;
String first = str.substring(e, i);
String rest = str.substring (i);
public class Bear
for (int i = 1; i< str. length(); i++)
public static ArrayList<String> breakups (String str)
if (str.length() > 1)
public static void main(String () args)
ArrayList<String> result = breakups ("bear");
for (String element : result)
ArrayList<String> result = new ArrayListo();
for (String s : shorter)
System.out.println(element);
result.add(first +""+ s);
return result:
Check
Feedback?
MacBook Pro
esc
く
!
$
%
&
*
1
2
4
6
7
8
Q
W
E
Y
U
P
A
S
D
G
H
J
K
R
Expert Solution

Step 1
Program Explanation:
- Import the Array List class
- Define a public class for implementing the given code
- Define a static method to generate the array list that contains all possible substrings for a given string
- Define the main method
- Make the method call with appropriate parameters
- Print the output
Trending now
This is a popular solution!
Step by step
Solved in 2 steps with 1 images

Recommended textbooks for you

Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON

Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science

Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning

Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON

Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science

Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning

Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning

Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education

Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY