Charged word-RAM histograms #
A fixed program clears a histogram and inserts the keys of a disjoint input array.
An insertion into a bucket of size c creates 2c ordered collisions. Every address
calculation, load, increment, store and loop test is charged.
Main definitions #
Histogram.count: bucket sizes in an input prefix.Histogram.pairs: ordered collisions accumulated by prefix insertion.Histogram.clearBlock: parameterized zeroing of[base..base+count)viazeroFill.Histogram.program: clear the buckets, then insert the input keys.
Main results #
Histogram.exec_clearBlock:4 * count + 6bound and frame forHistogram.clearBlock.Histogram.exec: histogram construction and collision counting with a linear instruction bound.
References #
The insertion counter counts exactly the ordered pairs of different positions with the same key, including when equal keys occur at different input positions.
Number of input keys.
Current bucket count.
Number of ordered collisions.
Clear [base..base+count) via zeroFill, loading zero = 0 and one = 1 and using cur
and stop as scratch cursor and end-address registers.
Clearing count cells with clearBlock executes in 4 * count + 6 instructions, leaves
zero = 0 and one = 1, and preserves every register distinct from cur, stop, zero, and
one.
Insert one key and add twice its old bucket count.
Clear the histogram, retaining the input and all four parameters.
Insert all keys into a cleared histogram.
Fixed code, with all bases and lengths supplied in registers.
Build a histogram and count ordered collisions within 4M + 11n + 10 native instructions.
The input keys lie in [0,M). The input precedes the output block. Both one-past-end
addresses and the quadratic counter bound must fit. These are explicit local contracts;
constructing the keys and deriving a logarithmic width are separate client obligations.