17.3k views
1 vote
Write a short recursive method that will find and return the leftmost node of a binary tree. Presume the method will initially be called with the root node as its input argument.

1 Answer

2 votes

Answer:

Node * leftmost(Node * root)

{

if(root==NULL)

return NULL;

return leftmost(root->left);

}

Step-by-step explanation:

This is the function to return the leftmost node of the Binary tree in C++.Return type of the function is Node.If root is NULL then we are returning NULL because there is no tree.Now we have to make a recursive call on root->left.

User Emily Gerner
by
4.6k points