算法导论 练习题 14.3-4

来源:互联网 发布:麦课在线网络通识学院 编辑:程序博客网 时间:2024/06/04 22:36
int overlapCount(pRBT root,KT i){pRBT x=root;int sum=0;if(!isOverlap(x->key,i) && x->max<i->low)return 0;else if(isOverlap(x->key,i)){ sum++;if(x->left)sum+=overlapCount(x->left,i);if(x->right)sum+=overlapCount(x->right,i);}else{if(x->key->high<i->low)sum+=overlapCount(x->right,i);if(x->key->low>i->high)sum+=overlapCount(x->left,i);}return sum;}