由买买提看人间百态

topics

全部话题 - 话题: dright
(共0页)
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;
}
c*****t
发帖数: 1879
2
来自主题: Programming版 - 请教算法题
buggy. You forgot the case where dleft == dright.
(共0页)