Question: template struct node { T key; S value; shared_ptr child; shared_ptr sibling; node(T key, S value) { this->key = key; this->value = value; child =

template

struct node {

T key;

S value;

shared_ptr> child;

shared_ptr> sibling;

node(T key, S value) {

this->key = key;

this->value = value;

child = NULL;

sibling = NULL;

}

};

Qs1)

template

bool Tree::insertChild(shared_ptr> newNode, T key) {

return false;

}

// This function returns all the children of a node with the given key

template

vector>> Tree::getAllChildren(T key) {

return vector>>();

}

// This function returns the height of the tree

template

int Tree::findHeight() {

return findHeightHelper(root);

}

// Helper function to find height of the tree

template

int Tree::findHeightHelper(shared_ptr> currNode) {

return 0;

}

// This function deletes the node of a given key (iff it is a leaf node)

template

bool Tree::deleteLeaf(T key) {

return false;

}

// Helper function to delete leaf node

template

shared_ptr> Tree::deleteLeafHelper(shared_ptr> currNode, T key) {

return NULL;

}

// This function deletes the tree

template

void Tree::deleteTree(shared_ptr> currNode) {

return;

}

// This function returns the root of the tree

template

shared_ptr> Tree::getRoot() {

return NULL;

}

code insertchild, getallchildren, findheight, findheighthelper, deleteleaf, deleteleaf helper, delete tree and get root in c++

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!