Question: This problem can be found on Chapter 12 p.718 question 27. Textbook: ADTs,Data Structures, and problem solving with c++ by larry nyhoff. The textbook solution
This problem can be found on Chapter 12 p.718 question 27. Textbook: ADTs,Data Structures, and problem solving with c++ by larry nyhoff. The textbook solution on chegg skips that problem.
I'm trying to implement a Text concordance(in c++) by storing each distinct word in an array of 26 binary search trees with the line number where the word was used in a linkedlist.
The program requirements go as follow:
1. Declares concord to be an array of 26 BSTs, one for each letter of the alphabet. Words that begin with 'a' or 'A' will be stored in the BST at concord[0], those that begin with 'b' or 'B' in the BST at concord[1], an so on. In general, words that begin with character ch will be stored in the BST at concord[upch - 'A'], where upch is the uppercase equivalent of ch. In addition to words, the concordance usually store a list of all numbers of pages on which a word appears. For each word, a linkedlist of all numbers of lines on which that word appeared in the input text.
Text file:
Ants and bats
and cows and cats
are animals
Cows are big
but ants are small
and cats are in
between
//end of text file
2. Reads strings of a file and for each string:
a. Removes all characters from it that are not letters and converts all letters to uppercase.
b. If the string isn't empty:
i. Searches the appropriate BST for the string
ii. If it's not found, inserts the string into the BST
3. Display the concordance with the words in alphabetical order and for each word the line numbers in ascending order where the word was used.
Thank you for the help.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
