# Minimum pair-wise XOR of elements from two sets

I have two sets, $$A$$ and $$B$$, which both contain a large amount of hashed values. What is the most efficient way of computing:

$$\min_{i,j} A_i \otimes B_j$$

• Hint: What is the smallest possible pair-wise XOR value? Can you think of an efficient way to find a pair that produces this value? – j_random_hacker Apr 1 at 0:56
• Well, the minimum is clearly 0, so I'm not sure where your hint is leading exactly. My guess would be to build a trie for B, and then check how far we can go down that trie with the complement of each element of A. – yawn Apr 1 at 1:51
• Sounds like you have an answer. Is there a reason you've rejected that? If you're asking whether it is possible to do better, it would be useful to edit the question describe the best algorithm you know of and analyze its running time. – D.W. Apr 1 at 2:15
• What is “large”? 100? A million? A billion? – gnasher729 Apr 1 at 6:01
• It would be totally easy if both arrays were sorted. – gnasher729 Apr 1 at 6:04