Question: #include BSTree.h template BSTree::BSTreeNode::BSTreeNode ( const DataType &nodeDataItem, BSTreeNode * leftPtr , BSTreeNode * rightPtr ) : dataItem ( nodeDataItem ) , left (
#include "BSTree.h
template
BSTree::BSTreeNode::BSTreeNode const DataType &nodeDataItem, BSTreeNode leftPtr BSTreeNode rightPtr
: dataItemnodeDataItem leftleftPtr rightrightPtr
nothing needs to be changed
template typename DataType, class KeyType
BSTree::BSTree
nothing needs to be changed
root ;
or
root nullptr;
template typename DataType, class KeyType
BSTree::~BSTree
nothing needs to be changed
clear;
template typename DataType, class KeyType
BSTree::BSTree const BSTree& other
root NULL;
this other;
template typename DataType, class KeyType
BSTree& BSTree:: operator const BSTree& other
if this &other
clear;
ifother.isEmpty
clonesub root, other.root ;
return this;
template typename DataType, class KeyType
void BSTree::insert const DataType& newDataItem
KeyType key newDataItem.getKey;
insertsub root, newDataItem, key ;
template typename DataType, class KeyType
void BSTree::clear
if root NULL
clearsub root ;
template typename DataType, class KeyType
bool BSTree::isEmpty const
if root NULL
cout "Empty tree" endl;
return true;
else
cout endl;
showHelperroot;
cout endl;
return false;
template
void BSTree::insertsub BSTreeNode& currentNode, const DataType& newDataItem, const KeyType& key
KeyType currentKey;
if currentNode NULL
currentNode new BSTreeNode newDataItem, NULL, NULL ;
else
currentKey currentNodedataItem.getKey;
if key currentKey
currentNodedataItem newDataItem;
else if key currentKey
insertsub currentNodeleft, newDataItem, key ;
else
insertsub currentNoderight, newDataItem, key ;
template
void BSTree::clonesub BSTreeNode& currentNode,
const BSTreeNode otherNode
currentNode new BSTreeNode otherNodedataItem, NULL, NULL ;
if otherNodeleft NULL
clonesub currentNodeleft, otherNodeleft ;
if otherNoderight NULL
clonesub currentNoderight, otherNoderight ;
template
void BSTree::clearsub BSTreeNode& currentNode
if currentNodeleft NULL
clearsub currentNodeleft ;
if currentNoderight NULL
clearsub currentNoderight ;
delete currentNode;
currentNode NULL;
end of inclass part
template typename DataType, class KeyType
bool BSTree::retrieve const KeyType& searchKey, DataType& searchDataItem const
return false;
template typename DataType, class KeyType
bool BSTree::remove const KeyType& deleteKey
return false;
template typename DataType, class KeyType
void BSTree::writeKeys const
template typename DataType, class KeyType
int BSTree::getHeight const
return ;
template typename DataType, class KeyType
int BSTree::getCount const
return ;
template typename DataType, class KeyType
void BSTree::writeLessThan const KeyType& searchKey const
#include "showcpp
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
