[Home]
[Contents]
[Chapter]
[Previous Algorithm]
[Next Algorithm]


K-d tree search


search( key, t ) typekey key[K]; tree t; { int lev, i; for ( lev=0; t != NULL; lev=(lev+1)%K ) { for ( i=0; i<K && key[i]==t->k[i]; i++ ); if ( i==K ) { found( t ); return; } if ( key[lev] > t->k[lev] ) t = t->right; else t = t->left; } notfound( key ); };

C source (352.srch.c)



© Addison-Wesley Publishing Co. Inc.