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


Binary priority queues insertion


procedure insert ( new : tree; var pq : tree ); begin if pq = nil then pq := new else if pq^.k <= new^.k then begin new^.left := pq; pq := new end else if pq^.left = nil then pq^.left := new else if pq^.left^.k <= new^.k then insert( new, pq^.left ) else insert( new, pq^.right ) end;

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



© Addison-Wesley Publishing Co. Inc.