/* Filename: bsttest.cpp Programmer: Br. David Carlson Date: October 10, 1997 Last Modified: December 4, 2001 This program inserts some hard-coded data (floats) into a binary search tree. It then tests the NumItems, Empty, and Find functions by calling them and reporting the results on the screen. Tested with: Microsoft Visual C++ 6.0 Microsoft Visual C++ .NET g++ under Linux */ #include "bstree.h" int main(void) { BSTClass BST; BSTNodePtr Result; cout << "Number of items in BST is " << BST.NumItems() << endl; if (BST.Empty()) cout << "BST is empty (correct)" << endl; else cout << "BST is not empty (incorrect)" << endl; cout << "Inserting data" << endl; BST.Insert(4.5); BST.Insert(-3.33); BST.Insert(12.6); BST.Insert(44.33); BST.Insert(12.56); cout << "Number of items in BST is " << BST.NumItems() << endl; if (BST.Empty()) cout << "BST is empty (incorrect)" << endl; else cout << "BST is not empty (correct)" << endl; Result = BST.Find(12.6); if (Result == NULL) cout << "The 12.6 could not be found in BST (incorrect)." << endl; else cout << "The 12.6 was found in BST (correct)." << endl; Result = BST.Find(6.6); if (Result == NULL) cout << "The 6.6 could not be found in BST (correct)." << endl; else cout << "The 6.6 was found in BST (incorrect)." << endl; return 0; }