Great Deal! Get Instant $10 FREE in Account on First Order + 10% Cashback on Every Order Order Now

COP-4338 Systems Programming Programming Assignment 6: I/O and Binary Search Due Date: Aug 2 at 11:59 PM (No LATE Submissions allowed) In this assignment, you are asked to write a C function with the...

1 answer below »
COP-4338 Systems Programming
Programming Assignment 6:
I/O and Binary Search
Due Date: Aug 2 at 11:59 PM (No LATE Submissions allowed)
In this assignment, you are asked to write a C function with the following signature that
spell-checks its first input parameter (which is a string/char a
ay) and returns 0 if it is not
spelled co
ectly:
int spellCheck(char* word, char* dictionaryFileName){. . . }
To perform spell-checking, you simply need to do binary search on the sorted list of
English words given in their co
ect forms in the file entitled “dictionary.txt” available on
Canvas along with the specification of this assignment. The name and path of this file is
passed to your function as the second input parameter.
Binary search can either be implemented using a binary search tree (taught in the class)
or using an iterative algorithm like the following:
int binsearch(char* dictionaryWords[],int listSize,char* keyword){
int mid, low = 0, high = listSize - 1;
while (high >= low) {
mid = (high + low) / 2;
if (strcmp(dictionaryWords[mid],keyword) < 0)
low = mid + 1;
else if (strcmp(dictionaryWords[mid],keyword)>0)
high = mid - 1;
else
eturn mid;
}
eturn -1;
not found
}
Submissions
You need to submit a .zip file compressing the C source file(s) related to the assignment (.c
files).
1
Answered Same Day Jul 28, 2021

Solution

Shweta answered on Aug 10 2021
147 Votes
Order62512/Instruction.txt
-> You need to change the file name according to your system location.
Order62512/spellcheck.c
#include int totalsize =0;
const int size =100;
int main()
{
    FILE *fp;
    char word[size];
    char c;
    if ((fp = fopen("C:/Users/Ace
Desktop/dictionary.txt","r")) == NULL){
printf("E
or! opening file");

Program exits if the file pointer returns NULL.
exit(0);
}

calculate total size of file.
for (c = getc(fp); c != EOF; c = getc(fp))
if (c == '\n')
Increment count if this character is newline
totalsize = totalsize + 1;

Input word to proceed for spell check
printf( "Enter a word...
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here