b******s 发帖数: 2 | 1 来自主题: Programming版 - 请教算法题 int isBTbalanced(node* pTree)
{
if(pTree == NULL)
return 0;
int dleft = isBTblanced(pTree->left);
int dright = isBTblanced(pTree->right);
if(dleft>=0 && dright >=0)
{
if(dleft>dright && dleft-dright<=1)
return dleft;
if(dleft
return dright;
}
return -1;
} |
|