Get the Height of a Node in a Binary Tree

Objective: Given a binary tree, find the height of a given node in the tree.

Input: A Binary Tree and a node

Output: Height of a given node in the tree.


Get The Height Of a Node

Get The Height Of a Node



  • Take a variable called height =0.
  • Search for that given node in the tree using recursion.
  • Each time you left or right , increase the height by 1.
  • Once you found the given node, return the height.
  • If till the end you wont find the node, return 0

Complete Code:

Output :
Height of the Node 25 is : 3

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.

You may also like...

%d bloggers like this: