Question: Please help code in C++ and provide explanation thank you. -------------------------------------------- -------------------------------------------- //BinarySearchTree.h #ifndef BINARY_SEARCH_TREE_H #define BINARY_SEARCH_TREE_H #include // for std::cout namespace BST_NS { template
Please help code in C++ and provide explanation thank you.
--------------------------------------------
--------------------------------------------
//BinarySearchTree.h
#ifndef BINARY_SEARCH_TREE_H
#define BINARY_SEARCH_TREE_H
#include
namespace BST_NS
{
template
class BinarySearchTree; //forward declaration
template
class TreeNode {
public:
TreeNode( ) : data(NULL), leftLink(NULL), rightLink(NULL) {}
TreeNode(T theData, TreeNode
: data(theData), leftLink(left), rightLink(right) {}
friend class BinarySearchTree
private:
T data;
TreeNode
TreeNode
};
// supply the pre and post conditions for each method
template
class BinarySearchTree {
private:
TreeNode
int tree_size;
public:
// default ctor
BinarySearchTree() : root(NULL), tree_size(0) {}
// copy ctor
BinarySearchTree(const BinarySearchTree& other);
// virtual dtor
virtual ~BinarySearchTree();
-----------------------------------------------
-----------------------------------------------
//BinarySearchTree.cpp
#include "BinarySearchTree.h"
/**Please help providing a correct implementation for the following:
// default constructor, also, do I need a copyTree() for this?
BinarySearchTree() : root(NULL), tree_size(0) {}
// copy constructor
BinarySearchTree(const BinarySearchTree& other);
// virtual destructor
virtual ~BinarySearchTree();
**/
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
