Question
In this program you will read two files and store their contents in arrays. You will sort both arrays, and then search an array for
In this program you will read two files and store their contents in arrays. You will sort both arrays, and then search an array for each element of the second array.
Program Steps
1. Open two input files and one output file.
2. Input files
a. HW2-dictionary.txt - this file contains 16000 words (please use a similar file of your own)
b. HW2-keywords.txt - this file contains 84 words (see below)
3. Read in these two files and store their contents in 2 arrays of strings. Do not use a vector.
4. Sort both arrays using either a selection sort, bubble sort or insertion sort. Use the same sort routine for sorting both arrays. Do not use the STL sort algorithm or quick sort.
5. Search the dictionary array for each keyword. If the keyword is not present in the dictionary array, write a message to the output file that the keyword is not found in the dictionary (see sample output below). Count the number of keywords not found. You will print this number at the end of the program.
Number of keywords not found = ?? <= the number is between 20 and 30
Required file output:
keyword not found: alignas
keyword not found: alignof
keyword not found: and_eq
keyword not found: asm
keyword not found: auto
keyword not found: bitand
keyword not found: bitor
keyword not found: char16_t
keyword not found: char32_t
keyword not found: compl
...
Additional Requirements
1. You must include at least two additional functions:
a. a sort function using either a bubble sort or an insertion sort
b. a search function that looks for each keyword in the dictionary array. You may use a function that is similar to the one that was presented in class.
c. Place the function definitions below main() and function prototypes above main().
The string class has less than, greater than, and equal operators (that's <, >, and ==). You'll find those quite useful for sorting and searching.
HW2-keywords.txt
for if nullptr break int long sizeof return short else friend const static_cast switch not auto extern and double case enum false and_eq float explicit decltype bitand continue dynamic_cast goto mutable new bitor inline bool catch namespace char compl asm const_cast not_eq operator class or_eq private export public typedef protected typeid register static reinterpret_cast template this struct throw true try default delete do typename union unsigned using virtual void volatile wchar_t while xor xor_eq alignas alignof char16_t char32_t constexpr signed noexcept static_assert thread_local or
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