What is the code below trying to print?
Posted: Wed Jul 13, 2022 7:42 pm
void print(tree *root,tree *node)
{
if(root ==null) return 0
if(root-->left==node || root-->right==node) || print(root->left,node)
||printf(root->right,node)
{
print(root->data)
}
}
a) just printing all nodes
b) not a valid logic to do any task
c) printing ancestors of a node passed as argument
d) printing nodes from leaf node to a node passed as argument
{
if(root ==null) return 0
if(root-->left==node || root-->right==node) || print(root->left,node)
||printf(root->right,node)
{
print(root->data)
}
}
a) just printing all nodes
b) not a valid logic to do any task
c) printing ancestors of a node passed as argument
d) printing nodes from leaf node to a node passed as argument