Question: C + + , Visual Studio. I have these four errors which I ve been told need to be fixed in my BinarySearchTree classes. I
C Visual Studio. I have these four errors which Ive been told need to be fixed in my BinarySearchTree classes. Im not sure what to fix in my classes and would appreciate a practical fix with comments. Due to formatting issues the includes and template is missing. It includes iostream and uses template class ItemType. Due to formatting I couldn't include the whole class.
BinarySearchTree.cpp: #include "BinarySearchTree.h #include "BinaryNodeTree.h #include "BinaryNode.h #include template auto BinarySearchTree::placeNodestd::sharedptr subTreePtr, std::sharedptr newNode
if subTreePtr nullptr return newNode; else if subTreePtrgetItem newNodegetItem subTreePtrsetLeftChildPtrplaceNodesubTreePtrgetLeftChildPtr newNode; else subTreePtrsetRightChildPtrplaceNodesubTreePtrgetRightChildPtr newNode; return subTreePtr; template
auto BinarySearchTree::removeValuestd::sharedptr subTreePtr, const ItemType target, bool& isSuccessful if subTreePtr nullptr isSuccessful false; else if subTreePtrgetItem target subTreePtr removeNodesubTreePtr; isSuccessful true; else if subTreePtrgetItem target std::sharedptr tempPtr removeValuesubTreePtrgetLeftChildPtr target, isSuccessful; subTreePtrsetLeftChildPtrtempPtr; else std::sharedptr tempPtr removeValuesubTreePtrgetRightChildPtr target, isSuccessful; subTreePtrsetRightChildPtrtempPtr; return subTreePtr; template
bool BinarySearchTree::addconst ItemType& newData auto newNodePtr std::makesharednewData; rootPtr placeNoderootPtr newNodePtr; return true; template auto BinarySearchTree::removeNodestd::sharedptr nodePtr if nodePtrgetLeftChildPtr nullptr nodePtrgetRightChildPtr nullptr
nodePtr nullptr; return nodePtr; else if nodePtrgetLeftChildPtr nullptrnodePtrgetRightChildPtr nullptr std::sharedptr nodeToConnectPtr nullptr; if nodePtrgetLeftChildPtr nullptr nodeToConnectPtr nodePtrgetLeftChildPtr; else nodeToConnectPtr nodePtrgetRightChildPtr; return nodeToConnectPtr; else auto tempPtr removeLeftmostNodenodePtrgetRightChildPtr nodePtrgetItem; nodePtrsetRightChildPtrtempPtr; nodePtrsetItemnodePtrgetItem; return nodePtr; template auto BinarySearchTree::removeLeftMostNodestd::sharedptr subTreePtr, ItemType& inorderSuccessor if subTreePtrgetLeftChildPtr nullptr inorderSuccessor subTreePtrgetItem; return removeNodesubTreePtr; else auto tempPtr removeLeftmostNodesubTreePtrgetLeftChildPtr inorderSuccessor; subTreePtrsetLeftChildPtrtempPtr;return subTreePtr; template auto BinarySearchTree::findNodestd::sharedptr treePtr,
const ItemType& target, bool& isSuccessful if treePtr nullptr return nullptr; else if treePtrgetItem target isSuccessful true; return treePtr; else if treePtrgetItem target return findNodetreePtrgetLeftChildPtr target, isSuccessful; else return findNodetreePtrgetRightChildPtr target, isSuccessful; template BinarySearchTree::BinarySearchTree template BinarySearchTree::BinarySearchTreeconst ItemType& rootItem :rootPtrstd::makesharedrootItem nullptr, nullptr template BinarySearchTree::BinarySearchTreeconst BinarySearchTree& tree rootPtr thiscopyTreetreerootPtr; template BinarySearchTree::~BinarySearchTree thisdestroyTreerootPtr; template int BinarySearchTree::getHeight const return thisgetHeightHelperrootPtr; template bool BinarySearchTree::isEmpty const return rootPtr nullptr; template int BinarySearchTree::getNumberOfNodes const return thisgetNumberOfNodesHelperrootPtr; template void BinarySearchTree::clear thisdestroyTreerootPtr; thisrootPtr.reset; template ItemType BinarySearchTree::getRootData const throwPrecondViolatedExcept if isEmpty throw PrecondViolatedExceptgetRootData called with empty tree."; return thisrootPtrgetItem; template void BinarySearchTree::setRootDataconst ItemType& newData const throwPrecondViolatedExcept if isEmpty thisrootPtr
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
