procedure mgram( t : patricia; m, k : integer; var pq : queue ); {*** Should start with an empty (minimum) priority queue, on returning, the priority queue contains the k most frequent m-grams ***} begin if wt(t) >= inspect( pq ) or size( pq ) < k then begin if t^.level >= BITS_PER_CHAR*m then begin if size( pq ) = k then delete( pq ); insert( t, pq ) end else begin if wt( t^.left ) > wt( t^.right ) then begin mgram(t^.right,m,k,pq); mgram(t^.left,m,k,pq) end else begin mgram(t^.left,m,k,pq); mgram(t^.right,m,k,pq) end end end end;