Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Define a class ArraySet using an array that represents a set and implements the

ID: 3704408 • Letter: D

Question

Define a class ArraySet using an array that represents a set and implements the SetInterface. Make the ArraySet resizeable. Then write a program that adequately demonstrates your implementation.

Define a class LinkedSet using a linked list that represents a set and implements the SetInterface. Then write a program that adequately demonstrates your implementation.

Use the either ArraySet or LinkedSet to create a spell checker. The set serves as a dictionary and contains a collection of correctly spelled words, which can be read from an external file. To see whether a word is spelled correctly, you see whether it is contained in the dictionary. To simplify your task, restrict your dictionary to a manageable size.

Place the words whose spelling you want to check into a set, which can be read from another exteranl file. The difference (set difference) between the dictionary (the set containing the correctly spelled words) and the set of words to be checked is a set of incorrectly spelled words.

Write a program that adequately demonstrates your implementation.

Explanation / Answer

program:

# include <iostream>           // FROM LIBRARY

#include <string.h>        //header fromm library

class LindSet

{------------------------------//starting fo the function

public:

char dictionary[1000];

char line[100];

void SetInterface(char[], char[]);

int letter(char c);

void remove(char line[]);

void toLower (char line[]);

void lowerDictionary (char dictionary[]);

int artlen(char line[]);

void nextlineword (char line[], char lineword[], int artlen, char dictionary []);

}

void main ()

{------------------------------//starting of the main function

   FILE *dict_file;

   FILE* line_file;

   int bytes_read;

char *p;

dict_file=fopen( "english.txt","r");

if dict_file==0)

{ cout<<" unable to open dictionary file "english.txt";

return -1;

}----------//ending of the function

p=dictionary;

p=gets(p,100,dict_file);

while(*p!='')

{ p+=1; }

p=gets(p,100,disct_file);

}

----------//ending of the function

p=line;

bytes_read=fread(p,1,1000,line_file);

p+=bytes_read;

}-----------//ending of the function

*p=0;

SetInterface(line,dictionary);

}----------//ending of the function

int linePosition=0;

int dictionaryPosition=0;

void SetInterface(char line[], char dictionary[])

{------------------------------//starting of the function

char lineWord[50];

char dictionaryWord[50];

int lineLength =artLen(line);

remove(line);

toLower(line);

lowerDictionary(dictionary);

nextLineWord(line,lineWord,lineLen,dictionary);

}----------//ending of the function

void nextDictionaryWord( char dictionary[], char dictionaryWord[])

{------------------------------//starting fo the function

int i;

for (i=0; dictionary[dictionaryPosrition] !=' '; i++)

{------------------------------//starting fo the function

dictionaryWord[i]=dictionary[dictionaryPosition];

dictionaryPosition ++;

}----------//ending of the function

}----------//ending of the function

int letter(char c)

{------------------------------//starting fo the function

if((c>='a' && c<='z') || (c>='A' && c<= 'Z'))

return 1;

return 0;

}

void remove(char line[])

{------------------------------//starting fo the function

int i,j=0;

for(i=0;line[i] !=0; i++)

{ if (letter(line[i]))

{ line[j]=line[i];

j++;

}----------//ending of the function

else if(letter(line[i]))

{ line[j]=' ';

j++;

} } }----------//ending of the function----------//ending of the function----------//ending of the function

void tolower(char line[])

{ int i=0;

for(i; line[i] !=0;i++)

{ if(line[i]>='A' && line[i]<='Z')

line[i]=line[i]+32;

}}----------//ending of the function----------//ending of the function

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote