subject

You are working on developing an electronic version of Scrabble. You are tasked with writing a variety of functions to this end. scrabble. txt is available in the hw4.zipand is a sorted, sanitized version of the Tournament Word List used in the US and Canada and based on the Official Scrabble Players Dictionary. Your job is to write a menu-basedsystem, name your source code file scrabble. c, that does the following: (a) Given a word determine if the word is in the Scrabble dictionary or not.
While you could perform a linear search through the dictionary that strategy is inefficient. As the dictionary is sorted you can employ a binary search strategy to find if the word is in the Scrabble dictionary or not. Do not use C library's bsearch() function. You must write your own binary search function.
(b) Given a set of tiles determine the best play. That is given a set of tiles determine the first word that is encountered that produces the maximum value of points.
The best play does not need to use all the tiles. For instance, if you have the following tiles abcdefg, the best play is decaf with a value of 11 points. For a given set of tiles there are (probably) multiple words with the same value, you only need to return one best play which is the first best play you find. Make sure you allow for duplicate tiles. For instance, if the user enters ccaabb, the best play is bacca for 11 points. Report to the user the best play and the value the play is worth. Scrabble assigns the following values to letters:
Letter A B C D E F G H I J K L M
Value 1 3 3 2 1 4 2 4 1 8 5 1 3
Letter N O P Q R S T U V W X Y Z
Value 1 1 3 10 1 11 4 8 4 10
As both menu items depend on the Scrabble dictionary, your first task is to load the dictionary into memory as an array of pointers to strings. You do this by declaring char **words and then allocating space for each word in the dictionary on the fly. As you don't know how much space you need beforehand you will employ a doubling of memory technique to ensure you allocate enough space. In the tarball the file integers. c contains sample code for reading in a file of integers (test data) that demonstrates the doubling technique. The sample code leaks memory. Make sure you have no memory leaks in your code. Check with valgrind.
For any string copy operations use strncpyo.
\$ ./scrabble
Scrabble Menu
1. find if a word is in the scrabble dictionary
2. determine best play from tiles
3. quit
Enter an option [1, 2, 3]: 1 enter word: scrabble
scrabble is a valid scrabble word
Scrabble Menu
1. find if a word is in the scrabble dictionary
2. determine best play from tiles
3. quit
Enter an option [1, 2, 3]: 1
enter word:
zxyzxy zxyzxy is not a valid scrabble word
Scrabble Menu
1. find if a word is in the scrabble dictionary
2. determine best play from tiles
3. quit
Enter an option [1, 2, 3]: 2
enter tiles as a word: ryzyt
best play is 'try' (6 points)
Scrabble Menu
1. find if a word is in the scrabble dictionary
2. determine best play from tiles
3. quit
Enter an option [1, 2, 3]: 3

ansver
Answers: 2

Another question on Computers and Technology

question
Computers and Technology, 21.06.2019 23:30
Acomputer is a multipurpose device that accepts input, processes data, stores data, and produces output, all according to a series of stored . the processing unit of most modern computers is a(n) . the instructions that tell a computer how to carry out a task are referred to as computer , which are distributed as software. computers run three main types of software: software, system software, and development tools. an example of system software is a computer system, which is essentially the master controller for all the activities that a digital device performs. digital devices are constructed using tiny electronic components that represent data bits as electrical signals. the system unit houses the system board, which contains several circuits made from semiconducting materials. computers come in three popular form factors: component, , and slate. many of today's digital devices operate on battery power supplied by ion batteries. battery life and lifespan can be extended by following good battery management practices.
Answers: 3
question
Computers and Technology, 22.06.2019 18:00
Which of the following physical laws can make the flow of water seem more realistic? a. motion b. gravity c. fluid dynamics d. thermodynamics
Answers: 2
question
Computers and Technology, 22.06.2019 20:00
What is the worst-case complexity of the maxrepeats function? assume that the longest string in the names array is at most 25 characters wide (i.e., string comparison can be treated as o( class namecounter { private: int* counts; int nc; string* names; int nn; public: namecounter (int ncounts, int nnames); int maxrepeats() const; }; int namecounter: : maxrepeats () { int maxcount = 0; for (int i = 0; i < nc; ++i) { int count = 1; for (int j = i+1; j < nc; ++j) { if (names[i] == names[j]) ++count; } maxcount = max(count, maxcount); } return maxcount; }
Answers: 3
question
Computers and Technology, 22.06.2019 21:40
Develop a function to create a document in the mongodb database “city” in the collection “inspections.” be sure it can handle error conditions gracefully. a. input -> argument to function will be set of key/value pairs in the data type acceptable to the mongodb driver insert api call b. return -> true if successful insert else false (require a screenshot)
Answers: 2
You know the right answer?
You are working on developing an electronic version of Scrabble. You are tasked with writing a varie...
Questions
question
Health, 02.01.2021 05:10
question
Mathematics, 02.01.2021 05:10
question
Mathematics, 02.01.2021 05:10
question
Mathematics, 02.01.2021 05:10
Questions on the website: 13722361