I want to find the first null child in a tree and return that node of the tree.
Im thinking something like this but it doesnt seem to work the way I want.
node *Find_Empty_Node(node* root)
{
int index = 0;
if(root)
{
if(root->data == 0)//<--I want this child
return tree->child[index];
for(int i = 0;i<root->child.size();i++)
{
Find_Empty_Node(root->child[i]);
index = i;
}
}
return tree;
}
and then back where is called do something like this?
node* curr = root;
curr = Find_Empty_Node(node* root);