A binary search tree (BST) is a binary tree, whose internal nodes each store a key and each have two sub-trees, commonly denoted left and right. The tree additionally satisfies the property: the key in each node must be greater than all keys stored in the left sub-tree, and smaller than all keys in the right sub-tree.
Let’s see how the BST data structure can be realized in C++ using a linked structure. We define three classes and use polymorphism as follows:
function.h
main.cpp
where
REQUIREMENTS:
Note:
1. This problem involves three files.
You will be provided with main.cpp and function.h, and asked to implement function.cpp.
2. For OJ submission:
Step 1. Submit only your function.cpp into the submission block.
Step 2. Check the results and debug your program if necessary.
There are three kinds of commands:
Each command is followed by a new line character.
Input terminated by EOF.
The output shows the result of each command.