This post is completed by 2 users

  • 0
Add to List

37. 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.


Get The Height Of a Node

Approach - Recursion:

  1. Take a variable called height=0.
  2. Search for that given node in the tree using recursion.
  3. Each time you go left or right, increase the height by 1.
  4. Once you found the given node, return the height.
  5. If tree is over and the element is not found, return 0



Height of the Node 25 is : 3