Re^2: Comparing a value to a list of numbersby LanX (Cardinal)
|on Jan 29, 2021 at 17:40 UTC||Need Help??|
Well, there is another question lurking behind, which is IMHO not too tangential
What if large ranges are involved? The OP showed at least a little one with 41-56.
I'm sure a binary search would outperform a hash then.°
(Of course not if using random keys like you did)
°) Well I need to be more precise: Large ranges are sometimes not practicable with hashes because of the memory complexity. This could lead to heavy swapping operations.
Having a little slower code with binary search O(ln) is often better than hash lookup with O(1)