I have to write an AVL tree for my data structures course and am stuck on calculating the balance factor for a subtree so that I know where and how to rotate the tree.

Thanks,
Eric

edit:

I know have to count to number of nodes in a binary tree.

```
private int countTotalNodes(AVLNode<T> start){

    AVLNode<T> current = start;

    if(current.getLeft() != null){
        return countTotalNodes(current.getLeft());
    }
    if(current.getRight() != null){
        return countTotalNodes(current.getRight());
    }
    return 1;

} 

```