Question: Computer Science Please compile the answer following the code given in the question, thanks. 1. (50 min) Complete the following BST program with main.cpp and

Computer Science

Please compile the answer following the code given in the question, thanks.

Computer Science Please compile the answer following the code given in the

question, thanks. 1. (50 min) Complete the following BST program with main.cppand bst.cpp. (a) bst.cpp // bst.cpp #include using namespace std; struct node/ode declaration { int d; struct node *l; struct node *r; };class bst { public: struct node *root; node * insert(node *r, int

1. (50 min) Complete the following BST program with main.cpp and bst.cpp. (a) bst.cpp // bst.cpp #include using namespace std; struct node /ode declaration { int d; struct node *l; struct node *r; }; class bst { public: struct node *root; node * insert(node *r, int v) { // recursively call the insert function - refer to algorithm return r; } node * deleteItem(node *p, int v) { if (p == NULL) return p; if (v d) else { if (v > p->d) else { if () // no child else if () // one child { } else // two child nodes { // use getSuccessor() here // used in delete function node * getSuccessor(node *p) { } if (p == void show(node *p, int lvl) { int i; if (p != NULL) { root) cout d d l, lvl + 1); cout r, lvl + 1); } } bst() { root = NULL; = } }; (b) main.cpp #include #include "bst.cpp" using namespace std; int main() { int c, i; bst tree; while (1) { cout > C; switch (c) //perform switch operation { case 1: cout > i; tree.root = tree.insert(tree.root, i); break; case 2: cout > i; tree.root = tree.deleteItem(tree.root, i); break; case 3: if (tree root == NULL) { cout

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!