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.
};
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.