Tries and Ternary Search Trees in Python and Javascript
http://jeethurao.com/blog/?p=146
woadwarrior / trie / overview — Bitbucket
Tries and Ternary Search Trees in Python and Javascript
Javascript , Python Add comments
There are a couple of places in which Tagz , where I needed efficient prefix matching. The most obvious way to do this is to use a Trie or a Ternary Search Tree . So, I ended up implementing both in Python. I’ve had this stuff lying around in my mercurial repo for Tagz for quite some time now. I just thought of releasing it today.
Interestingly, some crude benchmarks indicate that the trie implementation is more efficient than the ternary search tree implementation in terms of both speed and space (Look for test.py in the repo), I also ported the trie module to javascript, and its included in the repo.
Here are two GraphViz graphs visualizing both the structures, generated using the excellent GvGen library.
In the Ternary Search Tree graph, Blue vertices = left, Green vertices = middle, Red vertices = right.
The code can be found here .
查看更多关于Tries and Ternary Search Trees in Python and Javas的详细内容...
声明:本文来自网络,不代表【好得很程序员自学网】立场,转载请注明出处:http://haodehen.cn/did42640