edited by
812 views
0 votes
0 votes

Consider the following function with a binary tree with atleast one node:

int path(struct node *x, int len){
    if(x==NULL) return B;
    else return A;
}

Assume the above function is used “to check the given binary tree has any path with specified length from root to the leaf node”. Let $T$ be a binary tree with root pointed by $x.$  The function path $(x,10)$ returns non-zero if there exists any path from root to leaf has a path length $10.$ Otherwise returns $0$. Find $B$ and $A$ with recursive call of path?

$(1)$ $A$ is $path(x->left,len-1)||path(x->right,len-1)$ ,$B$ is $(len==1)$

$(2)$ $A$ is $path(x->left,len-1)||path(x->right,len-1)$ ,$B$ is $(len== -1)$


which of these two option correct? Please Explain. 

edited by

1 Answer

Related questions

0 votes
0 votes
1 answer
1
0 votes
0 votes
3 answers
2
thor asked Nov 27, 2016
4,234 views
The minimum size that an array may require to store a binary tree with n nodes$2^{\left \lceil(log_2(n+1)) \right \rceil -1}$$2n-1$$2n-n+1$$n+1$
2 votes
2 votes
3 answers
4