bool BinTree::is_avl(BintreeNode *r, int& height) { if (r == NULL) { height = 0; return true; } int hl,hr; bool is_avl_left = is_avl(r->get_left(), hl); if ( !is_avl_left ) return false; bool is_avl_right = is_avl(r->get_right(), hr); if ( !is_avl_right ) return false; int max = hl>hr ? hl:hr; if (2*max-hr-hl > 2) return false; height = max + 1; return true; }