Question: I will use C or C++, #define Nchars 27 /* a-z + ' */ typedef struct dictentry { // isEndOfWord is true if the node

I will use C or C++,

#define Nchars 27 /* a-z + ' */

typedef struct dictentry

{

// isEndOfWord is true if the node represents end of a word

bool isEndOfWord;

// Subsequent characters in words. Null pointers if there

// are no further words with the next letter.

struct dictentry *next[Nchars];

}

1) First, implement a dictionary tree that provides the abilities for a caller to insert words to a tree to build a dictionary and search the tree to find if a given word matches (case insensitive search) any stored word in the tree.

2)Then write code to test your dictionary tree implementation by building a dictionary tree from a source dictionary text file and then use the dictionary tree to perform spell checks on all words read from another text file and print out all misspelled words there.

In dictionary.h (in C or C++)

1. Search operation

In C, ResultType find(struct dictentry *dictnode, const char *word, const char *targetword);

In C++, dictentry::ResultType find(const char *word, const char *targetword=nullptr);

ResultType here could be an ENUM to indicate the result from the find call, suggested values are:

typedef enum {

CORRECT, // word has correct spelling

MISSPELLED,

BADCHARS, // word has characters outside [A-Z,az,']

ADDED, EXISTS,

} ResultType;

2. Insert Operation

In C, ResultType insert(struct dictentry *dictnode, const char *characters, const char *targetword);

In C++, ResultType insert(const char *characters, const char * targetword =nullptr);

In dictionary.c (for C) or dictionary.C (for C++) for implementing dictionary.h.

With the dictionary tree implementation, you need to write code to test the dictionary tree and generate output to be compared with the CORRECT output provided to you.

I will use C or C++, #define Nchars 27 /* a-z +

root node isEndofWord = false next[1] (b1) next[2] (c>2) isEndofWord=false isEndofWord =false next(0] (a>0) next[14] (o14) next[14] (0>14) isEndofWord false iSEndofWord=false isEndofWord=false next[19] (t>19) next[24] (y24) next[24] (y24) isEndofWord=true isEndofWord true isEndofWord=true next[2] (c->2) isEndofWord=false next[71 (h>7) isEndofWord true Figure 1- Tree dictionary representation of the words: bat, batch, boy, and coy. root node isEndofWord = false next[1] (b1) next[2] (c>2) isEndofWord=false isEndofWord =false next(0] (a>0) next[14] (o14) next[14] (0>14) isEndofWord false iSEndofWord=false isEndofWord=false next[19] (t>19) next[24] (y24) next[24] (y24) isEndofWord=true isEndofWord true isEndofWord=true next[2] (c->2) isEndofWord=false next[71 (h>7) isEndofWord true Figure 1- Tree dictionary representation of the words: bat, batch, boy, and coy

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!