Question
// Struct for nodes of the tree template struct node { T key; S value; shared_ptr child; shared_ptr sibling; node(T key, S value) { this->key
// Struct for nodes of the tree
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;
}
};
// Constructor
template
Tree
this->root = root;
}
// This function finds a key in the tree and returns the respective node
template
shared_ptr
return findKeyHelper(root,key);
}
// Helper function to find a key in the tree
template
shared_ptr
return NULL;
}
// This function inserts the given node as a child of the given key
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 all of these in c++
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started