/* treesClass.h
 * 
 * Program defines a binary tree base class and a binary search tree
 * derived class.  The main() tests out the various class methods.
 *
 */

#include<iostream>
#include<assert.h>

using namespace std;

typedef char elemType;

// binary tree node
struct nodeType {
   elemType data;		// store data
   nodeType * left;		// link to left subtree
   nodeType * right;		// link to right subtree
};

// binary tree class
class binaryTree {
protected:
   nodeType * root;  
private:
   void inorder (nodeType *) const;
   void preorder (nodeType *) const;
   void postorder (nodeType *) const;
   int nodecount (nodeType *) const;
   int max (int, int) const;
public: 
   // constructor
   binaryTree () {root = NULL;};

   // some tree information functions
   int treeNodeCount () const {return nodecount (root);};
        
   // tree traversals
   void postorderTraversal () const {postorder (root);};
   void inorderTraversal () const {inorder (root);};
   void preorderTraversal () const {preorder (root);};
};


// binary search tree class
class binarySearchTree : public binaryTree {
private:
   bool search (const elemType, nodeType *) const;
public:
   bool searchItem (const elemType key) {return search (key, root);};
   void insertItem (const elemType);
};
