Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

For this assignment, you will create a dictionary class that reads in a list of unsorted words into a STL (which is an implementation of

For this assignment, you will create a dictionary class that reads in a list of unsorted words into a STL (which is an implementation of a doubly linked list.) from a file called dictionary.txt You will use a list of dictionary entries (DictEntry). Next, you must sort the list. The list STL has a member function .sort which works as long as you have overloaded the < operator for the data type you are sorting). Now, you will read a list of words from a file called findwords.txt For each word in findwords.txt, you will search that list from the beginning of the list and if found, print (to the screen) how many searches/comparisons you had to make to find the word. Then you will search from the back of the list and print how many searches you had to make.

This will help you visualize that a Doubly Linked List might on average cut your search time in half by sorting the data, then choosing which end to start the search.

When complete print out each word with spaces in between in a file called revsorted.txt. Start at the back of the list so you end up with a reverse sorted list (words starting with z's first).

You will have a separate Dictionary class that uses a dictionary entry as defined with the Dicentry.h We do this to separate the dictionary methods from the type of data. If you were implementing your own doubly linked list, you would create a separate Node class. Remember, Nodes have data (which would be a dictionary entry), and forward and back pointers. Currently we are only using the word in DictEntry, but could easily use the definition, pronunciation, word history etc.

Extra Credit (up to 10 points!): In addition to the above implement the same functionality with a double linked list that you create with dynamically allocated pointers (replacing the STL list). So you would have a doubleLinkedList of dictEntry. You must note this in your readme.txt for credit.

------------------------------

Dictionary.txt is as follow:

Dog

cat

hippo

zebra

aardvark

---------------------------

findwords.txt is as follow

cat

dog

lion

zebra

----------------------------------

Dicentry.h is as follow

#ifndef DICTENTRY_

#define DICTENTRY_

#include

typedef std::string wordType;

class DictEntry

{

private:

wordType word;

wordType definition;

public:

wordType getWord(){return word;}

void setWord(wordType _word){word = _word;}

wordType getDef(){return definition;}

void setDef(wordType _def){definition = _def;}

bool operator < (const DictEntry &entry) const {

return (word < entry.word);}

};

#endif

USE LANGUAGE C++ only!! And you cant change the .h file and please dont send the same code we can get that answer from here only please send a different code different the other codes. THANK YOU!!!!!!

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

Modern Database Management

Authors: Jeffrey A. Hoffer Fred R. McFadden

4th Edition

0805360476, 978-0805360479

More Books

Students also viewed these Databases questions