Question: /* * This method determines whether or not a given String is an anagram of some subset of the * letters in the ArrayList .
/*
* This method determines whether or not a given String is an anagram of some subset of the
* letters in the ArrayList
*
* See:
* http://www.dictionary.com/browse/anagram
*
* The basic idea here is that we'll loop through each character in word, and remove each word from
* the ArrayList
* list.
*
* Example: Suppose list is the ArrayList
* then list.remove('e') changes list to [b, o, o, k, k, e, p, e, r].
* Calling list.remove('e') again changes list to [b, o, o, k, k, p, e, r].
*
* The remove method returns a boolean value. If the call changes the contents of the ArrayList the
* method returns true. If calling the method does not change the ArrayList then the method
* returns false.
*
* HINT: because this method will remove characters from ArrayList
* it is important to make a copy of what's in reference before using it. Write a loop that copies
* the contents of reference to a new ArrayList
*
*/
public boolean anagramOfLetterSubset(String word, ArrayList
// put your code here\
return false; // change the value returned
}
/*
* This method takes a word (a String) and a dictionary of words (an ArrayList
* a collection of words (a HashSet
*
* Put another way, this method finds all the words or length at least 2 that can be played from the
* letters in word.
*
* HashSet is a collection that, for our purposes in this homework, behaves like an ArrayList with
* the following exception:
* calling add(X) on a HashSet adds X only if X is not already in the collection
* In other words, HashSet does not allow duplicate entries. Because HashSet does not allow duplicates
* we get unique words in the result.
*
* HINT: in defining this method you should find a natural use for both string2charList and also
* anagramOfLetterSubset.
*/
public HashSet
HashSet
// put your code here
return words;
}
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
