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 {

//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 = 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; ielements.size(); i++)

s += to_string(root->elements[i]) + " ";

return s;

}

int main() {

std::vector v1 {30, 60}; std::vector v2 {10, 20};

std::vector v3 {40, 50}; std::vector v4 {70, 80};

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

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!