You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
obsidian-sync/日常学习/数据结构/trie树(字典树或前缀树).md

12 lines
744 B

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

字典树是一种空间换时间的数据结构又称Trie树、前缀树是一种树形结构(字典树是一种数据结构),典型用于统计、排序、和保存大量字符串
一个字典树的应用场景:在搜索框输入部分单词下面会有一些关联的搜索内容。
![[Pasted image 20231201103614.png]]
前缀树的三个性质:
+ 根节点不包含字符除了根节点每个节点都只包含一个字符。root节点不含字符这样做的目的是为了能够包括所有字符串
+ 从根节点到某一个节点,路过字符串起来就是该节点对应的字符串
+ 每个节点的子节点字符不同,也就是找到对应单词、字符是唯一的
![[Pasted image 20231201105100.png]]