How to solve this question

con you provide me pseudo code of this question with explain

@sksumitkumardiwaker,

The question says to find out whether a given binary tree is balanced or not. A non-empty binary tree T is balanced if:

  1. Left subtree of T is balanced
  2. Right subtree of T is balanced
  3. The difference between heights of left subtree and right subtree is not more than 1.
    Also, an empty tree is balanced.
    Algorithm:
  • Get the height of left and right subtrees.
  • Return true if difference between heights is not more than 1 and left and right subtrees are balanced, otherwise return false.

you can also optimize this approach further.