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


Binary priority queues insertion (Pascal version available)


tree insert( new, pq ) tree new, pq; { if ( pq == NULL ) return( new ); else if ( pq->k <= new->k ) { new->left = pq; return( new ); } else if ( pq->left == NULL ) pq->left = new; else if ( pq->left->k <= new->k ) pq->left = insert( new, pq->left ); else pq->right = insert( new, pq->right ); return( pq ); };

C source (516b.ins.c) Pascal source (516b.ins.p)



© Addison-Wesley Publishing Co. Inc.