Perfect hash function: Difference between revisions

Content deleted Content added
mNo edit summary
Construction: {{math}}
Line 55:
To evaluate the perfect hash function {{math|''h''(''x'')}} one only has to save the mapping &sigma; of the bucket index {{math|''g''(''x'')}} onto the correct hash function in the sequence, resulting in {{math|h(x) {{=}} &Phi;<sub>&sigma;(g(x))</sub>}}.<ref name="CHD" />
 
Finally, to reduce the representation size, the ({{math|&sigma;(i))<sub>0&le;i < r</sub>}} are compressed into a form that still allows the evaluation in {{math|''O''(''1'')}}.<ref name="CHD" />
 
This approach needs linear time in {{mvar|n}} for construction, and constant evaluation time. The representation size is in {{math|''O''(''n'')}}, and depends on the achieved range. For example, with {{math|''m'' {{=}} 1.23''n''}} {{harvtxt|Belazzougui|Botelho|Dietzfelbinger|2009}} achieved a representation size between 3.03 bits/key and 1.40 bits/key for their given example set of 10 million entries, with lower values needing a higher computation time. The space lower bound in this scenario is 0.88 bits/key.<ref name="CHD" />
Line 61:
===Pseudocode===
'''algorithm''' ''hash, displace, and compress'' '''is'''
(1) Split S into buckets {{math|B<sub>i</sub> :={{thin space=}} g<sup>-1</sup>({i})&cap;{{thin space}}S,0&le;i < r}}
(2) Sort buckets B<sub>i</sub> in falling order according to size |B<sub>i</sub>|
(3) Initialize array T[0...m-1] with 0's