News for hackers. Stuff that matters.
Re:Anagram Scoring by lisper on Tuesday February 21, 2017 @03:51PM (#13699811)
It's not entirely clear that the O(nk) solution actually wins because k is small in this case, and so log(k) is very small. Unless you do some careful bit packing, the O(nk) algorithm will use more memory, which could make it slower because of increased cache misses.
Re:Anagram Scoring by geocar on Wednesday February 22, 2017 @12:46AM (#13703336)
The O(nk) solution has fewer branches (O(1) versus O(log k)), and even if you use a naïve implementation, O(nk) will still fit into L1 (assuming n is bigger than k).
Re:Anagram Scoring by lisper on Wednesday February 22, 2017 @01:38AM (#13703568)
> O(nk) will still fit into L1

Not even close. The lexicon is 230k words, times 26 letters is nearly 6MB. The i7 has a 64kB L1 cache and a 246kB L2 cache.

I think the only way to resolve this would be to actually do the experiment. I wouldn't bet my life savings on the outcome either way, but I'll give you even odds at low stakes that sorting is faster.