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


Quad tree search


search( key, t ) typekey key[K]; tree t; { int i, indx, noteq; while( t != NULL ) { indx = noteq = 0; for (i=0; i<K; i++) { indx = indx << 1; if ( key[i] > t->k[i] ) indx++; if ( key[i] != t->k[i] ) noteq++; } if ( noteq ) t = t->p[indx]; else { found( t ); return; } } notfound( key ); };

C source (351.srch.c)



© Addison-Wesley Publishing Co. Inc.