Hashing & Randomized Algorithms

Answer & solution
Official answer: C
Universal hashing chooses a hash function randomly from a family with a bounded collision probability for distinct fixed keys, preventing an adversary from exploiting one known deterministic mapping. Division and multiplication with fixed constants can be targeted. Thus C under the standard model in which the selected random function is hidden or chosen independently of the adversary’s key set; unrestricted adaptive knowledge would require additional assumptions.
Teaching detail. For a universal family H, each distinct fixed pair x,y has collision probability at most 1/m when h is selected randomly from H. With chaining, the expected number of other keys colliding with a particular key is consequently bounded by (k−1)/m by linearity of expectation. Since k>m, some collisions are unavoidable by the pigeonhole principle: the goal is controlling concentrated collisions, not eliminating them. Random selection must be independent of the malicious fixed keys for this standard guarantee to apply.
![Question 54, GATE 2006: Given two length-n binary arrays a,b, find the longest interval [i,j] on which Σₖ₌ᵢʲaₖ=Σₖ₌ᵢʲbₖ, or report none. Which complexity describes the fastest method?
Options:
(A) O(3^n) and Ω(2^n) time if hashing is allowed
(B) O(n³) and Ω(n^2.5) time in the key-comparison model
(C) Θ(n) time and space
(D) O(√n) time only if the sum of all 2n entries is even](../../../assets/questions/CS-2006-Q54-1.webp)