Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Your Name: 15. (13 pts) In this problem you will be working with a dynamically l

ID: 3735903 • Letter: Y

Question

Your Name: 15. (13 pts) In this problem you will be working with a dynamically linked binary search tree (BST). Given a TA's Name: class BSTNode with the following private data members: BSTNode *mpLeft; BSTNode *mpRight; int mData; and the following public member functions: BSTNode (const int &newData;); BSTNode *& getLeft ) BSTNode *& getRight(): int getData ); and a class BST with the following private data member: BSTNode *mpRoot; Write an appropriate recursive insertNode () method that is a member of the BST class. The function should accept a reference to a pointer ("8) to a BSTNode and a const reference to the data to insert. The function does not need to return a value. However, no makeNode () function exists. hud(

Explanation / Answer

void insertNode(BSTNode *&temp, const string &data) {
   while(temp != NULL) {
       if(data <= temp->getData()) {
           temp = temp->getLeft();
       } else{
           temp = temp->getRight();
       }
   }
   temp = new BSTNode(data);
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote