Find the Deepest Left Node in a Binary Tree.

Objective: – Given a binary tree, Find the deepest left node in it.

Approach:

  • This approach is very similar to “Find the Deepest Node in a Binary Treewith little modification.
  • Take two global variable as “deepestlevel” and ” deepLeftNode“.
  • starting with level=0, Do the inorder traversal and whenever you go down one level ( root.left OR root.right), increase the level by 1.
  • Keep checking if current node is the left child and deepestlevel < level, if yes then update the “deepestlevel ” and “ deepLeftNode “.
  • At the end return “ deepLeftNode “, which will the deepest node value.
  • See the code for better explanation.

Code:


Output:

Deapest Left child is: 4

__________________________________________________
Top Companies Interview Questions..-

Google Microsoft Amazon Facebook more..

If you find anything incorrect or you feel that there is any better approach to solve the above problem, please write comment.
__________________________________________________

%d bloggers like this: