Timeline for Building prefix tree from dictionary, performance issues
Current License: CC BY-SA 3.0
5 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Apr 29, 2016 at 15:33 | comment | added | haldagan |
I'm not really sure of why this happens, but I doublechecked it back then - it was 35s versus 40s, while all other conditions were the same. I've just copypasted your code (except for print_r part). Unfortunately right now I have no access to mentioned environment to test it properly and tell you exact numbers. For now I will just wait if someone points out any errors in my class approach, which I can't notice.
|
|
Apr 29, 2016 at 14:59 | comment | added | Chris | interesting that it is slower - obviously i didn't benchmark any of them, though usually (in MY use cases) I've found the non-recursive approach is usually faster | |
Apr 29, 2016 at 14:54 | comment | added | haldagan |
>it may be something to do with how low-level of a construct the array is - this was my assumption too, however such a big difference is a question. Probably I'll just search some nested sets / trie library for php. As for recursion - you're right, yet having maximum word length of 25 it will make almost no difference if the _children array stores only pointers. By the way, your array solution is ~15% slower than mine (takes 5 more seconds to execute in the same conditions). However, I will try to get rid of recursion in class approach and see if it helps.
|
|
Apr 29, 2016 at 13:27 | review | First posts | |||
Apr 29, 2016 at 14:52 | |||||
Apr 29, 2016 at 13:26 | history | answered | Chris | CC BY-SA 3.0 |