Given a Binary tree, find out depth of the deepest odd level leaf node. Take root level as depth 1.
Input : Output : 5 Input : 10 / 28 13 / 14 15 / 23 24 Output : 3
We can traverse the tree starting from the root level and keep curr_level of the node.
Increment the curr_level each time we go to left or a right subtree.
Return the max depth of an odd level,if it exists.
1) return 0 if curr_node == NULL 2) if curr_node is leaf and curr_level is odd, return curr_level 3) else maximum(depthOdd(left subtree), depthOdd(right subtree))
Below is the implementation.
Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above.