program vanEmdeBoasPriorityQueueTester(input,output);
const N = 128;
type
vEB = ^node;
node = record
level : integer;
case typ : ( queue, single, array ) of
queue : ( min, max : integer;
top : vEB;
bot : array[0..15] of vEB );
single : ( val : integer );
array : ( vals : set of 0..3 )
end;
procedure insert( new : integer; var pq : vEB );
var ibot, botkey : integer;
begin
with pq^ do begin
ibot := new div sqrtn;
botkey := new mod sqrtn;
if bot[ibot] <> nil then insert( botkey, bot[ibot] )
else begin
bot[ibot] := NewNode( sqrtn, botkey );
insert( ibot, top )
end;
if max < new then max := new;
if min > new then min := new
end
end;
|