资源 · 指南或文章
Trie
讲解前缀树:节点的位置编码了它的键,所有后代都共享该节点的前缀,因此适合以字符串为键的查找。
审核日期
打开原站: Trie (在新标签页中打开原网站)练习这个主题打开练习面试官,并带上一道关于 树 的题目。
添加到路线图
把这个资源放进你正在跟进的路线图。它会作为你自己的补充资源显示;路线图的步骤不会改变,也不计入你已记录的步骤。
来源内容语言:英语
Read this in other languages: 简体中文, Русский, Português, Українська, 한국어 In computer science, a trie, also called digital tree and sometimes radix tree or prefix tree (as they can be searched by prefixes), is a kind of search tree—an ordered tree data structure that is used to store a dynamic set or associative array where the keys are usually strings. Unlike a binary search tree, no node in the tree stores the key associated with that node; instead, its position in the tree defines the key with which it is associated. All the descendants of a node have a common prefix of the string associated with that node, and the root is associated with the empty string. Values are not necessarily associated with every node. Rather, values tend only to be associated with leaves, and with some inner nodes that correspond to keys of interest. For the space-optimized presentation of prefix tree, see compact prefix tree.
PrepKit 概览
本概览由 PrepKit 编辑根据源代码仓库撰写并审核,并非资源本身的文字。
- 适合人群
- 来源未说明适用级别
- 形式
- 参考资料
涵盖内容
- 字典树与二叉搜索树在键的存储位置上有何不同
- 根节点代表空字符串,值保存在叶节点和部分内部节点上,并提到压缩前缀树
使用建议
这是 PrepKit 的学习建议,并非来源的说法。
实现 insert、search 和 startsWith,然后用字典树返回所有具有给定前缀的已存储单词。
范围与局限
页面上没有操作、复杂度或自动补全示例;实现细节留给维基百科和 YouTube 链接。
获取方式与形式
GitHub 上的简短 README,trekhleb/javascript-algorithms(MIT),附有五种译本的链接。英文,免费。
PrepKit 于 2026年10月2日 审核。 资源来源提交: 85293e3e2b88
本概览的依据
- src/data-structures/trie/README.md
收录此条目的页面
订阅 PrepKit 通讯
可选。使用 PrepKit 并不需要订阅。