Leftist trees distance (
Pascal version
available)
int distance( pq ) tree pq; { return( pq==NULL ? 0 : pq->dist ); }; fixdist( pq ) tree pq; { tree temp; if ( distance(pq->left)
right) ) { temp = pq->right; pq->right = pq->left; pq->left = temp; }; pq->dist = distance(pq->right) + 1; };
C
source (516.dist.c)
Pascal
source (516.dist.p)
©
Addison-Wesley
Publishing Co. Inc.