educative.io

What makes a tree 'balanced'? - Data Structures for Coding Interviews in Python

Quiz explanation at the bottom of this seems to have the wrong answer. Unclear why the tree is unbalanced since the heights appear to be the same at every level. Typo?

1 Like

@Karthik_Hariharan The tree is indeed unbalanced. Try ignoring the null nodes since they are there to only make assertions that there is no child. For nodes with no left and right child, they are left as it is but only for the case of one Child node, the other is being pointed to null node.

Best Regards,
Ali Ahad | Developer Advocate
Educative.io

@Ali_Ahad still didn’t understand can you make a representation like in the exercise?
like this:
image

also the null pointers there is to show what is left or right node, right?

At node 2, HLT is 2 and HRT is 0 the difference will be more than 1. Hence, it is false.