//Xac dinh so nut tren cay
int nb_nodes(TTree T) {
    if(EmptyTree(T)) return 0;
    else return (nb_nodes(T->left)+nb_nodes(T->right)+1);
}
//Xac dinh so nut la
int nb_leaf(TTree T) {
    int leaf = 0;
    if (!EmptyTree(T)) {
        if(IsLeaf(T)) leaf++;
        else (leaf=nb_leaf(LeftChild(T))+nb_leaf(RightChild(T)));
    }
    return leaf;
}
//Ham xac dinh gia tri lon nhat trong 2so nguyen
int max(int value1, int value2) {
    return ((value1>value2)?value1:value2);
}
//Xac dinh chieu cao cua cay
int TreeHeight(TTree T) {
    int height=0;
    if (!EmptyTree(T)) {
        height=((TreeHeight(LeftChild(T)) > TreeHeight(RightChild(T))) ? TreeHeight(LeftChild(T)) : TreeHeight(RightChild(T))) +1;
    }
    return height;
}
//Doi cay con ben trai thanh ben phai
void Change(TTree *T){
     TTree P;
     if ((!EmptyTree(T) && (T->left!=NULL) && (T->right!=NULL)){
        P=T->left;
        T->left=T->right;
        T->right=P;
        Change(T->left);
        Change(T->right);
     }
}