In text processing, it is common to study the number of distinct words used in the text together with their word counts. You can assume that all the words are in lowercase and no punctuation marks are in the text; and we would like to use BST to store and to sort all the distinct words.
The following shows the node structure to be used for constructing the BST:
struct Node;
typedef Node* NodePtr;
struct Node
{
char * word;
int count;
NodePtr left, right;
};
For example, if you are given the following text file called infile.txt: see image.
Upon execution of your program, the following table is displayed on screen; as can be seen that the words (left column) are sorted in order: see image.