I read in a book named “Coding Interview Cracked”, that to check whether a BST is balanced or not, just find out the difference between the maximum and minimum height but I not sure whether it is 100% correct. Though I am unable to find a counter test case.
Can anyone confirm whether this approach is correct or not.
For checking whether a tree is balanced or not.
|MaxHieght(root) - MinHieght(root)| <=1
return true
else return false
Given the definition of balanced (from the Wiki of Pedias)
This seems correct. Since the minHeight and maxHeight are going to be equal to the height of either side, looks like the definition holds