void rrangesearch(TREENODE *subroot, VECTOR *vpLow, VECTOR *vpHigh, int level){ #ifdef DEBUG printf("recursive tree range search was called with \n"); vecprint(vpLow); vecprint(vpHigh); printf("level=%d\n", level); #endif /*** this part was disabled, for homework1 **/ int numdims; if( subroot != NULL ){ numdims = (subroot->pvec)->len; if( contains( vpLow, vpHigh, subroot->pvec ) ){ vecprint(subroot->pvec); } if( (vpLow->vec)[level] <= ((subroot->pvec)->vec)[level] ){ /* left branch can not be excluded */ rrangesearch( subroot->left, vpLow, vpHigh, (level+1)% numdims); } if( (vpHigh->vec)[level] > ((subroot->pvec)->vec)[level] ){ /* right branch can not be excluded */ /* notice the '>' as opposed to '>=' */ rrangesearch( subroot->right, vpLow, vpHigh, (level+1)% numdims); } } /*****/ return; }
void rangesearch(TREENODE *subroot, VECTOR *vpLow, VECTOR *vpHigh){ #ifdef DEBUG printf("tree range search was called with \n"); vecprint(vpLow); vecprint(vpHigh); #endif rrangesearch(subroot, vpLow, vpHigh, 0); }
void rrangesearch(TREENODE *subroot, VECTOR *vpLow, VECTOR *vpHigh, int level){ /*** this part was disabled, for homework1 **/ int numdims; if( subroot != NULL ){ numdims = (subroot->pvec)->len; if( contains( vpLow, vpHigh, subroot->pvec ) ){ vecprint(subroot->pvec); } if( (vpLow->vec)[level] <= ((subroot->pvec)->vec)[level] ){ /* left branch can not be excluded */ rrangesearch( subroot->left, vpLow, vpHigh, (level+1)% numdims); } if( (vpHigh->vec)[level] > ((subroot->pvec)->vec)[level] ){ /* right branch can not be excluded */ /* notice the '>' as opposed to '>=' */ rrangesearch( subroot->right, vpLow, vpHigh, (level+1)% numdims); } } /*****/ return; }
void rangesearch(TREENODE *subroot, VECTOR *vpLow, VECTOR *vpHigh){ rrangesearch(subroot, vpLow, vpHigh, 0); }