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


Quad tree insertion


tree insert( key, t ) typekey key[]; tree t; { int i, indx, noteq; if ( t==NULL ) t = NewNode( key ); else { 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->p[indx] = insert( key, t->p[indx] ); else Error; /*** Key already in table ***/ } return( t ); };

C source (351.ins.c)



© Addison-Wesley Publishing Co. Inc.