Given a Binary Tree, find the deepest leaf node that is left child of its parent. For example, consider the following tree. The deepest left leaf node is the node with value 9.
1 / \ 2 3 / / \ 4 5 6 \ \ 7 8 / \ 9 10
The idea is to recursively traverse the given binary tree and while traversing, maintain “level” which will store the current node’s level in the tree. If current node is left leaf, then check if its level is more than the level of deepest left leaf seen so far. If level is more then update the result. If current node is not leaf, then recursively find maximum depth in left and right subtrees, and return maximum of the two depths. Thanks to Coder011 for suggesting this approach.
The deepest left child is 9
Time Complexity: The function does a simple traversal of the tree, so the complexity is O(n).
This article is contributed by Abhay Rathi. Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above
- Deepest left leaf node in a binary tree | iterative approach
- Deepest right leaf node in a binary tree | Iterative approach
- Find the Deepest Node in a Binary Tree
- Depth of the deepest odd level node in Binary Tree
- Find depth of the deepest odd level leaf node
- Print all leaf nodes of a Binary Tree from left to right
- Closest leaf to a given node in Binary Tree
- Get maximum left node in binary tree
- Change a Binary Tree so that every node stores sum of all nodes in left subtree
- Print the longest leaf to leaf path in a Binary tree
- Sum of all leaf nodes of binary tree
- Product of all leaf nodes of binary tree
- Find the closest leaf in a Binary Tree
- Count Non-Leaf nodes in a Binary Tree
- Pairwise Swap leaf nodes in a binary tree