Think about Loose Coupling | |
PerlMonks |
Re^2: Comparing a value to a list of numbersby LanX (Saint) |
on Jan 29, 2021 at 17:40 UTC ( [id://11127652]=note: print w/replies, xml ) | 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)
Cheers Rolf
update°) 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)
In Section
Seekers of Perl Wisdom
|
|