We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
字典树常用来进行字符串检索,例如用给定的字符串序列建立字典树。对于目标字符串,只要从根节点开始深度优先搜索,即可判断出该字符串是否曾经出现过,时间复杂度为O(n),n可以认为是目标字符串的长度。
如果Trie是二叉树那么O(n)没有问题,但多叉树的情况或许这么说不太准确? 搜索了一些英文资料,普遍写成时间复杂度是O(W*L), W: Number of Words, L: Length.
O(n)
O(W*L)
W
L
Ref: Trie complexity and searching Trying to Understand Tries
The text was updated successfully, but these errors were encountered:
@MuyaoXiao ,感谢 issue,我看了一下原文,O(W*L) 是说创建 trie 的时间复杂度,我在里面写的是搜索的
Sorry, something went wrong.
喔!每次找一层是hash的 sorry for my stupid issue
@MuyaoXiao ,没事,阅读过程有问题欢迎随时反馈~
cch123
No branches or pull requests
如果Trie是二叉树那么
O(n)
没有问题,但多叉树的情况或许这么说不太准确?搜索了一些英文资料,普遍写成时间复杂度是
O(W*L)
,W
: Number of Words,L
: Length.Ref:
Trie complexity and searching
Trying to Understand Tries
The text was updated successfully, but these errors were encountered: