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
shared_ptr
node(T key, S value) {
this->key = key;
this->value = value;
child = NULL;
sibling = NULL;
}
};
Qs1)
template
bool Tree
return false;
}
// This function returns all the children of a node with the given key
template
vector
return vector
}
// This function returns the height of the tree
template
int Tree
return findHeightHelper(root);
}
// Helper function to find height of the tree
template
int Tree
return 0;
}
// This function deletes the node of a given key (iff it is a leaf node)
template
bool Tree
return false;
}
// Helper function to delete leaf node
template
shared_ptr
return NULL;
}
// This function deletes the tree
template
void Tree
return;
}
// This function returns the root of the tree
template
shared_ptr
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
Get step-by-step solutions from verified subject matter experts
