Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Plz need C++ code with the same output Spellchecker Source code is already given below only need the code in a section where asked to

Plz need C++ code with the same output Spellchecker

Source code is already given below only need the code in a section where asked to fill it up

Specifications

You will be given a menu-driven shell program with a working menu for a rudimentary spellchecker. The spellchecker will use a linear search and a binary search to check the spelling of a word by comparing it to a dictionary of words. Due to memory constraints, the dictionary itself will not be read into memory, but you have been supplied code that will parse the dictionary and save each entry's file position offset to an array. The dictionary is already sorted, and contains only words with lowercase characters.

Be sure you understand how the shell program works, the functions it calls, and the parameters that are passed. You should not need to change any of the shell code. You simply need to provide the missing functionality: A linear search routine (10 pts) and a binary search routine (10 pts). Be sure to test the edge cases (the first word of the file, the last word of the file, and a non-existing word) as well as known words (5 pts). Use only the random file access methods to retrieve data from the open (which the shell code takes care of for you). I would suggest using the getline() function provided by (see the parsing code already supplied), as the use of any other data access method might not be compatible with the file position indexes.

In your comment header, write a few sentences concerning any performance differences you see between your linear and binary search functions (5 pts). Don't forget to include your name! (2 pts)

Sample input/output

Indexing the word file:

image text in transcribedimage text in transcribedimage text in transcribed

Only needed to fill up the section where it asked to add the c++ code.

source file

// COSC 1437 - Lab 4 (your name here) #include "Header.h" #include using namespace std; // This array will hold > 64KB and needs to be declared globally // (alternatively, we could create it on the heap using dynamic allocation). // The size of streamoff is implementation-dependent. streamoff index[400000]; int main() { int indexSize = -1; string filename; int option; ifstream input; do { cout > option; if (option == 1) { cout > filename; indexSize = indexWordFile(index, filename, input); cout > word; bool result = linearSearch(index, indexSize, word, input); if (result) { cout > word; bool result = binarySearch(index, indexSize, word, input); if (result) { cout // Your code here! return false; } bool binarySearch(streamoff index[], int size, string word, ifstream& input) { // Your code here!

return false; }

Header file

#include #include #include using namespace std; int indexWordFile(streamoff index[], string filename, ifstream& input); bool linearSearch(streamoff index[], int size, string word, ifstream& input); bool binarySearch(streamoff index[], int size, string word, ifstream& input);

I only posted a words file for only A cause it too long to post all words upto Z.

words.txt file

a aa aaa aah aahed aahing aahs aal aalii aaliis aals aam aardvark aardvarks aardwolf aardwolves aargh aaron aaronic aarrgh aarrghh aas aasvogel aasvogels ab aba abac abaca abacas abacate abacaxi abacay abaci abacinate abacination abacisci abaciscus abacist aback abacli abacot abacterial abactinal abactinally abaction abactor abaculi abaculus abacus abacuses

1. Index the word file 2. Linear search 3. Binary search 4. Quit 1 Enter filename: words.txt Number of words indexed: 355543 1. Index the word file 2. Linear search 3. Binary search 4. Quit 1. Index the word file 2. Linear search 3. Binary search 4. Quit 2 Enter word: a Word found! 1. Index the word file 2. Linear search 3. Binary search 4. Quit 2 Enter word: syzygy Word found! 1. Index the word file 2. Linear search 3. Binary search 4. Quit 2 Enter word: zyzzyvas Word found! 1. Index the word file 2. Linear search 3. Binary search 4. Quit Enter word: laskjdfljk Word not found... 1. Index the word file 2. Linear search 3. Binary search 4. Quit Enter word: a Word found! 1. Index the word file 2. Linear search 3. Binary search 4. Quit Enter word: syzygy Word found! 1. Index the word file 2. Linear search 3. Binary search 4. Quit Enter word: zyzzyvas Word found! 1. Index the word file 2. Linear search 3. Binary search 4. Quit Enter word: lakjsdlfkja Word not found... 1. Index the word file 2. Linear search 3. Binary search 4. Quit

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

Refactoring Databases Evolutionary Database Design

Authors: Scott Ambler, Pramod Sadalage

1st Edition

0321774515, 978-0321774514

More Books

Students also viewed these Databases questions