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. The remove method of the ArrayList removes ONE occurrence from the

* list.

*

* Example: Suppose list is the ArrayList that prints as [b, o, o, k, k, e, e, p, e, r]

* 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 working with,

* 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 reference) {

// put your code here\

return false; // change the value returned

}

/*

* This method takes a word (a String) and a dictionary of words (an ArrayList) and returns

* a collection of words (a HashSet) that are anagrams of some subset of the letters in word.

*

* 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 possibleWords(String word, ArrayList dictionary) {

HashSet words = new HashSet();

// put your code here

return words;

}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!