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 // for std::cout

namespace BST_NS

{

template

class BinarySearchTree; //forward declaration

template

class TreeNode {

public:

TreeNode( ) : data(NULL), leftLink(NULL), rightLink(NULL) {}

TreeNode(T theData, TreeNode* left, TreeNode* right)

: data(theData), leftLink(left), rightLink(right) {}

friend class BinarySearchTree;

private:

T data;

TreeNode* leftLink;

TreeNode* rightLink;

};

// supply the pre and post conditions for each method

template

class BinarySearchTree {

private:

TreeNode *root;

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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!