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

There’s something not correct. Height of Node x => 25 should be 1 not 3. Can you check it please?

tutorialhorizon

We are considering the height here as number of nodes above the particular node (including the node itself)

sunny kansal

Still output and solution is wrong…Height of Node is the longest path till its leaf node…And it should be 1 for Node 25 not 3…but the number of levels are 3…

arefin nowshad

This code seems like calculating depth of a node. Even that is actually wrong, depth should be 2 for Node 25 and height is 1. You cant consider the height as the number of nodes above the particular node including the node itself as the right way to define height of a node. Because this is outright wrong. http://stackoverflow.com/questions/2603692/what-is-the-difference-between-tree-depth-and-height