loading...

re: Trie - Data Structure & Algorithm Part VI VIEW POST

TOP OF THREAD FULL DISCUSSION
re: Nice example, and very nicely explained. I'd be keen to discuss this though... While for your example I can see it working well, finding everythi...
 

Thanks for your comment! After reading it, I believe I was misunderstood because I did not explain it correctly.

I’ll try to improve the implementation of this code and see the effect when the number of items is increasing, but, as I said, my code was just a simple example of trie structure. And it is necessary to consider that the native associative array/hash of the javascript will have better results because already have a nice well-optimized implementation. That said, the array will be more faster than most general purposes.

I agree with you when you said that the trie isn't an O(1) as a hash-table... But the trie can perform better in some complex problems, such as a search engine or autocomplete feature comparing with the hash table structure. Because we have to consider an imperfect associative array and it's almost impossible to create a uniform random distribution to avoid conflicts that lead to handling collisions by separate chaining or linear/double/Quadratic Proibing, the time to calculate the hash table, memory accesses...

I did't understand the problem in your project, but if you want, you can describe more and I can try to help you :)

code of conduct - report abuse