Just another Perl shrine | |
PerlMonks |
Re: searching problem (reverse substrings)by LanX (Saint) |
on Jan 18, 2013 at 10:33 UTC ( [id://1014030]=note: print w/replies, xml ) | Need Help?? |
You mean matching only from the start? Your sorting technique sounds clever, but the sorting itself isn't constant, I suppose something like O(n*log(n)). IMHO the fastest solution should be a trie, if it's worth the overhead depends on the number of words to search. Another simpler approach is abusing the regex engine, because from 5.10 on it has internal trie optimization and is f*ckingly fast!
thats untested pseudo-code I hope you get the idea! =)
UPDATEnow tested:
Cheers Rolf
In Section
Seekers of Perl Wisdom
|
|