Question: THE DICTIONARY HAS TO BE HARD CODED INTO THE PROGRAM, YOU CANNOT INPUT THE .TXT FILE ONLY WORDS OF LENGTH 3 or MORE ARE TO

THE DICTIONARY HAS TO BE HARD CODED INTO THE PROGRAM, YOU CANNOT INPUT THE .TXT FILE

ONLY WORDS OF LENGTH 3 or MORE ARE TO BE OUTPUTTED

Solving the game of Boggle can be done elegantly with recursion and backtracking. Backtracking is a technique whereby an algorithm recognizes it is impossible or unnecessary to search any deeper into the search space from a given point. An example of this is finding your way through a maze. When you hit a dead end you mark that last step as a dead end and avoid going down that path. A fast and efficient solution to Boggle requires a hueristic that helps you recognize a dead end and save vast amounts of wasted searches (and thus vast amounts of time).

Boggle is a board game that uses 16 dice arranged in a 4 x 4 grid. There is also a 5x5 version. Each die has 6 faces with a letter of the alphabet on it. Occasionally the string "Qu" will appear on a dice face. A typical board might look like this.

The Assignment

Your program MUST produce exactly the same output my solution produces on each boggle input file. You are to hard code the dictionary.txt filename somewhere inside your program and always load that file as your dictionary of legal words. For this assignment there is only one dictionary file we will ever use. So, go ahead and hard code the "dictionary.txt" filename in your code. Your program should be executed as follows:

$ java Boggle 4x4-board.txt 

The only output is to be the real dictionary words you found in the grid. One word per line. No other output of any kind. The words must be unique, no duplicates and they must appear in sorted order ascending from top to bottom. Please see my correct output files below and make sure your solution has the same exact words as mine.

dictionary.txt 172822 words. Your reference dictionary

INPUT FILES TO RUN YOUR SOLUTION ON

A good solution will find all the dictionary words in the grid in under 1/4 of a second from the time the program started running till it printed out the last valid word to the screen.

4x4-board.txt:

4 qu e a i n e r e t w s t o r k y 

all real dictionary words you should find -> 4x4-board-output.txt

http://people.cs.pitt.edu/~hoffmant/S17-401/project-10/4x4-board-output.txt

5x5-board.txt:

5 a f b c i r k n d p z k n v w e j e u b t w f j o 

all real dictionary words you should find -> 5x5-board-output.txt:

http://people.cs.pitt.edu/~hoffmant/S17-401/project-10/5x5-board-output.txt

10x10-board.txt:

10 q e t u o a d g j l z s x d c f v g b h w r y i p s f h k z a w d r g y j i l v q s e f t h u k o l q z w x e c r v t b i g b s d w f h l z w f h b c t r u h y q n g c d r f y u i x v n k h f w t i a 

all real dictionary words you should find -> 10x10-board-output.txt

http://people.cs.pitt.edu/~hoffmant/S17-401/project-10/10x10-board-output.txt

HERE IS A GOOD PSEUDO CODE OUTLINE:

FOR TESTING PURPOSES CREATE A QUICK 'n DIRTY GRID TO TEST WITH SO THAT YOU DONT HAVE TO READ IN THE GRID FROM A FILE IN ORDER TO GET SOMETHING WORKING THIS APPROACH WILL GERENRATE AND PRINT EVERY POSSIBLE STRING FROM THE GRID MAIN() { String[][] board = { {"a","b"}, {"c,"d"} }; // 2 X 2 -or- String[][] board = { { "a","b","c" }, { "d","e","f" }, { "g","h","i"} }; // 3 X 3 -or- String[][] board = { { "a","b","c","d" }, { "e","f","g","h" }, { "i","j","k", "l"}, { "m","n","o","p" } }; // 4 X 4 for r=0 to  

The links will take you to the outputs that have to match the code that is ran. It would have been to long to post all the words. A regular dictionary is to be hard coded into the program that contains every word in a reference dictionary that will be used to find all the words that are in each boggle game.

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!