CSC 7000-002 Algorithms & Programming
Fall 1999, Mendel 115
Dr. David Matuszek
The idea of this assignment is to read in words and sort them alphabetically. The purpose of this assignment is to introduce recursion and recursively defined data structures.
Your program is to:
The result should be an alphabetized list of words, with each output line containing one word along with the number of times it occurred.
You need to keep a pointer (initially NULL) to a binary tree, which you
might define as follows:
typedef struct node node;
typedef node *binary_tree;
struct node {
char *word;
int count;
binary_tree left;
binary_tree right;
};
Here's how you insert words, given a word and a (possibly NULL) a
"binary tree" pointer:
NULL, create a new node, fill in its fields (the word,
count=1, NULL, NULL), and set the pointer to point
to this node.NULL, compare the word in the node to which it points
(use strcmp()).Here's how you do an inorder traversal of a binary tree:
NULL, do nothing, otherwise In this assignment, when you "visit" a node, print out the node contents: the word and its count.
You will be graded more strictly than in the past on (1) following directions, (2) good style, (3) good comments, and (4) appropriate use of functions. In addition, your program will be examined for any obvious memory leaks.