Question: need c++ format; need implement search and remove function BSTNode * BST ::search(const K& key) Should return a pointer to the found node, if not

need c++ format;

need implement search and remove function

  • BSTNode* BST::search(const K& key)
    • Should return a pointer to the found node, if not found return nullptr.
  • bool BST::remove(const K& key)
    • Leave this function to implement to last. However the destroy function should be implemented no matter what since we are using dynamic memory.
data.h *************************************** #include  #include  template  class Data { public: explicit Data(const T& myData) : data(myData) {} Data() = delete; T getData() const { return data; } void print(std::ostream& outfile = std::cout) { outfile  

need c++ format; need implement search and remove function BSTNode* BST::search(const K&key) Should return a pointer to the found node, if not found

include template BSTNode delete data; ) K getKey) const return key: h DatacT>getData) const freturn data; ) void setLeft (BSTNode K,T* const node) left- node; void setRight(BSTNodeK,T>* const node) { right node; } BSTNode& rhs) const return key * left = nullptr; BSTNode& operator-(const BSTNode6) -delete ; template bool remove (const K& key) // Implement remove node EST() { destroy(root); } BSTNode K,T* rootnullptr template * BST* subtree) template void BSTK, Trint (std::ostream& outfile, const BSTNode T,subtree) const template typename K, typename bool BST K, T remove(const K& key) template typename typename BSTNodeK,T BSTK,Tsearch(const K& key) nain.cpp #include "BST.h" int main BSTint,int> tree: tree.add(50, 50) tree.add (40, 40); tree. add(60, 60); tree.add(55, 55); tree.print(); return O 0: include template BSTNode delete data; ) K getKey) const return key: h DatacT>getData) const freturn data; ) void setLeft (BSTNode K,T* const node) left- node; void setRight(BSTNodeK,T>* const node) { right node; } BSTNode& rhs) const return key * left = nullptr; BSTNode& operator-(const BSTNode6) -delete ; template bool remove (const K& key) // Implement remove node EST() { destroy(root); } BSTNode K,T* rootnullptr template * BST* subtree) template void BSTK, Trint (std::ostream& outfile, const BSTNode T,subtree) const template typename K, typename bool BST K, T remove(const K& key) template typename typename BSTNodeK,T BSTK,Tsearch(const K& key) nain.cpp #include "BST.h" int main BSTint,int> tree: tree.add(50, 50) tree.add (40, 40); tree. add(60, 60); tree.add(55, 55); tree.print(); return O 0

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 Databases Questions!