除了能求高度,还能判断树是否平衡
int node_depth(node_tp node, int * blance)
{
int l, r;
if(!node)
return 0;
l = node_depth(node->left, blance);
r = node_depth(node->right,blance);
if(blance && (l - r > 1 || l - r < -1))
{
*blance = 0;
printf("\ncha=%d, %d", l-r, node->data);
}
return 1 + ((l > r)? l:r);
}