what, if anything, is missing?

Hi, I have the headers to a binary tree and it's node class. These headers are not mine but they appear to be missing some methods. It could be nothing but i'd like a second opinion:

1
2
3
4
5
6
7
8
9
10
11
12
13
template < class Comparable>
class TreeNode {
    
  public:  
	  Comparable  item;         // The data in this node.
      TreeNode *left;   // Pointer to the left subtree.
      TreeNode *right;  // Pointer to the right subtree.
		
      TreeNode  (Comparable value) ;     // Constructor.  Makes a node containing value.
          
      TreeNode  (Comparable value, TreeNode *leftTree, TreeNode *rightTree) ;
                // Constructor. 
};


Tree class:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
template <class Comparable>
class Tree{
	void copyTree(TreeNode<Comparable>* &copy,
		TreeNode<Comparable>* other);
public :
	TreeNode< Comparable> *root ;
	Tree () {    // dedault constructor 
	root = NULL ;
	}
		   
	Tree  (Comparable value) ;  // constructor ;create a single node tree

	Tree(Comparable value , Tree left, Tree right) ;  // constructor 

	Tree (Tree  &other) ;   // copy constructor

	Tree(TreeNode<Comparable> *r );   //  constructor taking a pointer to a tree node

    Tree & operator = (const Tree &rhs) ;        // overload assignment operator

	~Tree(){	// destructor
		delete root;
	}
};



Can this be done with no copyTree or destroynode methods? I've been reading a lot about trees and they all seem to have methods used by the copy, and overload assignment constructors that recursively copy or delete tree nodes.

This is an assignment so I'd really rather not go adding methods to the headers i've been given but if I have to, I will. Thanks in advance.
Last edited on
Topic archived. No new replies allowed.