Question: Consider the permutations method from the textbook, which is intended to return all permutations of the word passed in as a parameter. Which line contains
Consider the permutations method from the textbook, which is intended to return all permutations of the word passed in as a parameter. Which line contains the terminating condition in the permutations recursive method?
public static ArrayList permutationsString word
ArrayList result new ArrayList;
if wordlength line #
result.addword; line #
return result; line #
else
for int i ; i word.length; i line #
String shorter word.substring i wordsubstringi ; line #
ArrayList shorterPermutations permutationsshorter; line #
for String s : shorterPermutations line #
result.addwordcharAti s; line #
return result; line #
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
