Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a program that solves a word search puzzle in c++. The program reads an n x n grid of letters from a file and

Write a program that solves a word search puzzle in c++. The program reads an n x n grid of letters from a file and prints out all the words that can be found in the grid. Words can be found in the array by starting from any letter and reading left, right, up, down, or along any of the four diagonals. Words can also wrap around the edges of the array. Letters can be used more than once in a particular word. Words must be at least 5 characters long.The list of k possible words is included in the file wordlist. Several sample word search puzzles are also provided. The goal is to find an algorithm that solves this problem that runs as quickly as possible for large n and k.

Sample word search puzzles

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

wordlist.text:

flooding bidders abatises stingily trawls teated undercrofts objectivists dissatisfied undernourished universal fancywork tyranny gruesomeness abbreviated ear utmost boar hornswoggles 

image text in transcribed

Write a program that solves a word search puzzle. The program reads an n x n grid of letters from a file and prints out all the words that can be found in the grid. Words can be found in the array by starting from any letter and reading left, right, up, down, or along any of the four diagonals. Words can also wrap around the edges of the array. Letters can be used more than once in a particular word. Words must be at least 5 characters long. The list of k possible words is included in the file wordlist. Several sample word search puzzles are also provided The goal is to find an algorithm that solves this problem that runs as quickly as possible for large n and k Part a 1. Implement a class called wordList that stores the word list in a vector, and which includes: (a) a function to read the words from the wordlist file (b) an overloaded output operator to print the word list (c) functions that sort the words using 1) insertionSort, 2) quickSort, and 3) mergeSort (d) a function to handle word lookups using binary search 2. Implement a class called grid that reads the letters in the grid from a file and stores them in a matrix 3. Implement a global function findMatches) that is passed the word list and the grid as parameters and which prints out all words that can be found in the grid . Implement a global function search(int) which reads the name of the grid file from the keyboard and prints out all words from the word list that can be found in the grid. The function should also print out the CPU time to sort the words, the CPU time to find the words, and the total time. The integer parameter is used to select the sorting algorithm used The code you submit should demonstrate the correct behavior of your code using the three sorting algorithms. After each sorting algorithm sorts the original word list, print out all the words that can be found in the grid and the timing information described above

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions