here how to update the max level correctly,i am unable to get like how to reduce the max level back to original level value when we are going for right side
??
Tree top view (max_level updation eror)
@Vibhuti0206 hey ,just update the maxlevel when current level is greater than maxlevel ,as right view is there so called right recursion with increase in current level ,here is the code snippet:
if (*max_level < level)
{
cout << root->data << “\t”;
*max_level = level;
}
// Recur for right subtree first,
// then left subtree
rightViewUtil(root->right, level + 1, max_level);
rightViewUtil(root->left, level + 1, max_level);
}
i basically want to pass the level also recursively
i basically want to pass the max level also recursively
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.