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


Auxiliary functions for B-tree insertion (Pascal version available)


btree NewNode( k1, p0, p1 ) typekey k1; btree p0, p1; {btree tempr; tempr = (btree)malloc( sizeof( node ) ); tempr->p[0] = p0; tempr->p[1] = p1; tempr->k[0] = k1; tempr->d = 1; return( tempr ); } InsInNode( t, key, ptr ) btree t, ptr; typekey key; {int j; for( j=t->d; j>0 && key<t->k[j-1]; j-- ) { t->k[j] = t->k[j-1]; t->p[j+1] = t->p[j]; } t->d++; t->k[j] = key; t->p[j+1] = ptr; }

C source (342.iin.c) Pascal source (342.iin.p)



© Addison-Wesley Publishing Co. Inc.