Question: //main.cpp #include #include #include #include using namespace std; struct BTreeNode { bool is_leaf=true; std::vector elements; std::vector children; BTreeNode() {} BTreeNode (std::vector v) { this->elements =

//main.cpp
#include
#include
#include
#include
using namespace std;
struct BTreeNode {
bool is_leaf=true;
std::vector
std::vector
BTreeNode() {}
BTreeNode (std::vector
this->elements = v;
}
};
BTreeNode* find(BTreeNode* root, int key) {
// Your Code Here
return NULL;
}
string convert(BTreeNode* root) {
string s = "";
if (root==NULL) return s;
for (int i=0; i
s += to_string(root->elements[i]) + " ";
return s;
}
int main() {
std::vector
std::vector
BTreeNode n_0(v1), n_2(v2), n_3(v3), n_4(v4);
n_0.children.push_back(&n_2);
n_0.children.push_back(&n_3);
n_0.children.push_back(&n_4);
n_0.is_leaf = false;
BTreeNode* ans;
ans = find(&n_0, 110);
string found = (ans != NULL? "Yes :) In Node ":"No. ");
cout
ans = find(&n_0, 80);
found = (ans != NULL? "Yes :) In Node ":"No. ");
cout
ans = find(&n_0, 10);
found = (ans != NULL? "Yes :) In Node ":"No. ");
cout
ans = find(&n_0, 30);
found = (ans != NULL? "Yes :) In Node ":"No. ");
cout
return 0;
}
The Problem Complete the member function find in main.cpp that accepts a BTree BTreeNode and an int val, and must return the BTreeNode that contains that matches the val or NULL if val was not found Example: in main. Cpp, an exmaple BTree has been provided to help you test your code: find val 30 [30 601 [10 20] 40 501 170 801 Expected output Yes In Node 30 60 Compile and Test A complete Makefile and a main. cpp file containing some simple tests have been provided for you. To compile and run, run: make ./main The Problem Complete the member function find in main.cpp that accepts a BTree BTreeNode and an int val, and must return the BTreeNode that contains that matches the val or NULL if val was not found Example: in main. Cpp, an exmaple BTree has been provided to help you test your code: find val 30 [30 601 [10 20] 40 501 170 801 Expected output Yes In Node 30 60 Compile and Test A complete Makefile and a main. cpp file containing some simple tests have been provided for you. To compile and run, run: make ./main
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
