added algorithm to check whether BST is balanced.