CS 153 Data Structures I
Assignment #10
Due: 4/5/01
Purpose: to learn about binary search trees (BST)
Options: you can write this program in either dialog or console mode
Description of operation:
-
The user should first enter the name of a file.
You can think of this file as being a small dictionary. The words
in the file should be read and stored in the BST.
-
When the program reaches end-of-file display all of the
words in the binary search tree by calling
-
Then, the user will enter the name of a second file.
This second file can be thought of as a list of words to check against the
dictionary. As you go through the second file, you should check
to see if the word is already in the BST. If the word is there, do
nothing, and go on to the next word. If the word is not in the BST,
it should be added to the BST.
-
Again, when the program reaches end-of-file display all
of the words in the binary search tree.
-
In this program you will be inserting nodes into a container,
so the concepts are familar. However, instead of a node having a previous
and next pointer, each node will have a left child and a right child.
The struct that you will need is shown below.
You will also need a BST Class. The class should be able to insert
a node, find a node, and traverse the tree for output purposes. Your
BST class might look something like the one shown below.