Question
In c++ format please, for each function in the code, using the comments fill in the function to write the whole program. #include #include using
In c++ format please, for each function in the code, using the comments fill in the function to write the whole program.
#include
void destructorHelper(NodePtr root);
//private helper function for the destructor
//recursively frees the memory in the BST
void inOrderPrintHelper(NodePtr root); //private helper function for inOrderPrint //recursively prints tree values in order from smallest to largest void preOrderPrintHelper(NodePtr root); //private helper function for preOrderPrint //recursively prints tree values in preorder void postOrderPrintHelper(NodePtr root); //private helper function for postOrderPrint //recursively prints tree values in postorder /**Public functions*/ public: BST(); //Instantiates a new Binary Search Tree //post: a new Binary Search Tree object
~BST();
//frees the memory of the BST object
//All memory has been deallocated
bool isEmpty(); //determines whether the Binary Search Tree is empty void insert(bstdata value); //inserts a new value into the Binary Search Tree //post: a new value inserted into the Binary Search Tree bstdata getRoot(); //returns the value stored at the root of the Binary Search Tree //pre: the Binary Search Tree is not empty void inOrderPrint(); //calls the inOrderPrintHelper function to print out the values //stored in the Binary Search Tree //If the tree is empty, prints nothing void preOrderPrint(); //calls the preOrderPrintHelper function to print out the values //stored in the Binary Search Tree //If the tree is empty, prints nothing void postOrderPrint(); //calls the postOrderPrintHelper function to print out the values //stored in the Binary Search Tree //If the tree is empty, prints nothing };
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started