Question
This is for C++ The goals of this assignment are: Create and use functions Implement pass-by-reference and pass-by-value function coupling Use character arrays and the
This is for C++
The goals of this assignment are:
- Create and use functions
- Implement pass-by-reference and pass-by-value function coupling
- Use character arrays and the cstring library
- Use an array of struct to model a collection
- Use file i/o
The program you need to write in this assignment will prompt the user for an input text file name, and then generate a keyword index for the file. A "keyword index" is a list of every distinct word that appears in the file, followed by the lines in which the word appears. For example, if the input file is:
as1> more input This This This is a line is a line done This line
Then the keyword index would be:
Keyword Index: "This" appears on lines: 1 5 "a" appears on lines: 2 3 "done" appears on lines: 4 "is" appears on lines: 2 3 "line" appears on lines: 2 3 6
Note the following details:
- Each word in the file appears only one time in the index, no matter how many times it appears in the file.
- The index is presented in "ASCII code order", not the order in which the words are encountered in the input file.
- The list of lines for each word is presented in ascending order. Each line appears only once, no matter how many times the word appears on a line.
The algorithm for creating a keyword index is:
- Read a word from the input file
- Scan the index and determine if the word is already present in the index
- If the word is not already in the index, insert the word in the proper position in the index
- Scan the list of lines for the word to determine if the current file line number is already in the list of lines
- If the current file line number is not already in the list of lines, insert the current file line number in the proper position in the list of lines
- Repeat until no more words in the file
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