Question
The purpose of this program is to read a text file and store words and the line numbers on which they occur, to be printed
The purpose of this program is to read a text file and store words and the line numbers on which they occur, to be printed to another text file and screen. This project in a way brings you a tiny step closer to the search engine technology. You must use a Binary search tree as well as any other data structure needed. Proceed as follows: 1. Design a class called WordList, which is given below partially. You will need to add to it as per need of the program. In place of class you can also use WordList struct. Still all the same member functions and data members (as WordList class) would be needed.
Class WordList{ private: /** *Stores the word from text file */ string Word; /** *Stores the line numbers (as integers) on which the Word is found */ SinglyLinkedList LineNumList; //Add any other data members as per your need. public: /** *Reads data from the file or keyboard to fill the WordList object */ friend istream & operator >>(istream & in, WordList& WL); /** *Writes data to the file or to screen to print the WordList object */ friend ostream & operator <<(ostream & out, const WordList& WL); /** *Virtual destructor */ virtual ~ WordList ( ); //Add any other member functions, as you need. For example, you //will need to overload the following operators, so that WordList //can be placed in a binary search tree: operators >, <, and ==. }; The suggested UML of WordList class may look like below.
Insert WordList objects into the Binary search tree such that when printing the tree, using an In-order iterator, the words are printed alphabetically
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started