Question: Write a program that uses recursive backtracking to generate all anagrams from a phrase typed by the user. An anagram is a word or phrase

Write a program that uses recursive backtracking to generate all anagrams from a phrase typed by the user. An anagram is a word or phrase made by rearranging the letters of another word or phrase. For example, the words “midterm” and “trimmed” are anagrams. If you ignore spaces and capitalization and allow multiple words, a multi-word phrase can be an anagram of some other word or phrase. For example, the phrases “Clint Eastwood” and “old west action” are anagrams. Your program will read a dictionary file of words and search for all words that can be formed using the letters in the user’s phrase. Use backtracking to choose each word, explore what can be made out of the remaining letters, then un-choose the word afterward. Here is a possible example dialogue:

Phrase to search? barbara bush

Max words to use? 3

[abash, bar, rub]

[abash, rub, bar]

[bar, abash, rub]

[bar, rub, abash]

[rub, abash, bar]

[rub, bar, abash]

Step by Step Solution

3.41 Rating (160 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

Answer from inventory import Lettering entity class Anagram Solver def initself words Expects words ... View full answer

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 Building Java Programs A Back to Basics Approach Questions!