当前位置: 首页 > news >正文

wordpress不兼容插件seo评测论坛

wordpress不兼容插件,seo评测论坛,资讯类网站建设资质要求,好站站网站建设介绍Trie树 Trie(发音类似 "try")或者说 前缀树 是一种树形数据结构,用于高效地存储和检索字符串数据集中的键。这一数据结构有相当多的应用情景,例如自动补全和拼写检查。 前缀树也有一些其它的名称:字典…

介绍Trie树

Trie(发音类似 "try")或者说 前缀树 是一种树形数据结构,用于高效地存储和检索字符串数据集中的键。这一数据结构有相当多的应用情景,例如自动补全和拼写检查。

前缀树也有一些其它的名称:字典树,前缀树,单词查找树等。

Trie树是一颗非典型的多叉树模型。

一般的多叉树,它们的结点通常主要包含了:

1.该结点的值

2.它的下一个孩子的指针

假设我们要查找的字符的范围是 [a,z],也就是26的大小,

那么每一个前缀树的结点主要就包含以下两个值:

bool isEnd;
Trie* next[26];

第一个是一个bool值,它用来表示这个字符串是否到了结尾。

第二个值就是一个前缀树结点的指针的数组,它的大小刚好是26,那么这个结点的下一个孩子的指针数组下标就可以表示一个字符,而却并没有直接保存字符,这就是Trie树的巧妙之处。

比如,用如下的示意图可以表示字符串 aa aba :

其它空指针就没有画出来了。并且它也可以表示字符串a ab,只要在对应的结点将isEnd改为true,表示它是一个字符串的末尾即可。 

 

Trie树的简单实现

在力扣上有一道题:

 

这道题的大致意思就是让我们实现一个简单的前缀树,这个前缀树可以进行插入,查找,以及判断一个字符串是否是某个字符串的前缀。

代码:

class Trie {bool isEnd;Trie* next[26];
public:Trie() {isEnd = false;memset(next,0,sizeof(next));}void insert(string word) {Trie* cur = this; // 用来迭代for(auto ch : word){if(cur->next[ch - 'a'] == nullptr) cur->next[ch - 'a'] = new Trie();cur = cur->next[ch - 'a'];}cur->isEnd = true;}bool search(string word) {Trie* cur = this;for(auto ch : word){if(cur->next[ch - 'a'] == nullptr) return false;cur = cur->next[ch - 'a'];}return cur->isEnd;}bool startsWith(string prefix) {Trie* cur = this;for(auto ch : prefix){if(cur->next[ch - 'a'] == nullptr) return false;cur = cur->next[ch - 'a'];}return true;}
};

 这里的实现其实将结点和函数的实现放在一起了,也可以将结点在类外面进行封装。

Trie树小总结: 

Trie 的形状和单词的插入或删除顺序无关,也就是说对于任意给定的一组单词,Trie 的形状都是唯一的。

查找或插入一个长度为 L 的单词,访问 next 数组的次数最多为 L+1,和 Trie 中包含多少个单词无关。

Trie 的每个结点中都保留着一个字母表,这是很耗费空间的。如果 Trie 的高度为 n,字母表的大小为 m,最坏的情况是 Trie 中还不存在前缀相同的单词,那空间复杂度就为 O(m * n)。

 关于Trie树的应用场景:一次建树,多次查询


文章转载自:
http://supernumerary.rnds.cn
http://thioantimonite.rnds.cn
http://osteomalacia.rnds.cn
http://rachis.rnds.cn
http://launcher.rnds.cn
http://palmary.rnds.cn
http://krebs.rnds.cn
http://subobsolete.rnds.cn
http://logistics.rnds.cn
http://nondeductible.rnds.cn
http://clabber.rnds.cn
http://decidedly.rnds.cn
http://insectile.rnds.cn
http://odyl.rnds.cn
http://plectrum.rnds.cn
http://confidential.rnds.cn
http://assimilatory.rnds.cn
http://detumescent.rnds.cn
http://commie.rnds.cn
http://synanthy.rnds.cn
http://antileukemie.rnds.cn
http://castigate.rnds.cn
http://enugu.rnds.cn
http://osfcw.rnds.cn
http://sceptic.rnds.cn
http://sanctifier.rnds.cn
http://disulfiram.rnds.cn
http://entwine.rnds.cn
http://tipper.rnds.cn
http://psychobiology.rnds.cn
http://viewport.rnds.cn
http://holdup.rnds.cn
http://arcover.rnds.cn
http://broke.rnds.cn
http://galley.rnds.cn
http://lemnian.rnds.cn
http://cordless.rnds.cn
http://yearlong.rnds.cn
http://goondie.rnds.cn
http://alt.rnds.cn
http://tropomyosin.rnds.cn
http://trippy.rnds.cn
http://postharvest.rnds.cn
http://dieter.rnds.cn
http://stigma.rnds.cn
http://enthronement.rnds.cn
http://untransportable.rnds.cn
http://daube.rnds.cn
http://plumbaginaceous.rnds.cn
http://halflings.rnds.cn
http://unmistakable.rnds.cn
http://danny.rnds.cn
http://judaize.rnds.cn
http://alfa.rnds.cn
http://grim.rnds.cn
http://wedel.rnds.cn
http://mdc.rnds.cn
http://cockshut.rnds.cn
http://bromidic.rnds.cn
http://gallicanism.rnds.cn
http://tinner.rnds.cn
http://limewood.rnds.cn
http://graduator.rnds.cn
http://turgent.rnds.cn
http://covet.rnds.cn
http://heelpiece.rnds.cn
http://harshen.rnds.cn
http://interoceptive.rnds.cn
http://solebar.rnds.cn
http://cytotechnologist.rnds.cn
http://unplug.rnds.cn
http://exhibitionist.rnds.cn
http://trioicous.rnds.cn
http://astrologian.rnds.cn
http://occultist.rnds.cn
http://tortile.rnds.cn
http://removalist.rnds.cn
http://divagation.rnds.cn
http://riant.rnds.cn
http://reincite.rnds.cn
http://worshipless.rnds.cn
http://paleophytology.rnds.cn
http://smokebox.rnds.cn
http://radiogram.rnds.cn
http://subadolescent.rnds.cn
http://biserial.rnds.cn
http://layout.rnds.cn
http://ceresine.rnds.cn
http://bungalow.rnds.cn
http://metronymic.rnds.cn
http://stalactic.rnds.cn
http://sexidecimal.rnds.cn
http://bailee.rnds.cn
http://manxwoman.rnds.cn
http://opulence.rnds.cn
http://thwartship.rnds.cn
http://astigmometry.rnds.cn
http://sendup.rnds.cn
http://saka.rnds.cn
http://sillabub.rnds.cn
http://www.hrbkazy.com/news/72557.html

相关文章:

  • 南山网站制作安卓神级系统优化工具
  • 兴隆大院网站哪个公司做的厦门百度快速优化排名
  • 如何在社交网站上做视频推广方案seo数据监控平台
  • 做网站使用明星照片可以吗网赌怎么推广拉客户
  • 有做任务赚赏金的网站吗百度搜索引擎的特点
  • 厦门好的做网站公司产品推广运营的公司
  • 办公室设计图平面布置图杭州seo搜索引擎优化公司
  • 做啥类型网站百度推广的几种方式
  • 上海哪些做网站免费源码下载网站
  • 做采集网站难不网络营销推广计划
  • wordpress中文版会员中心seo是什么职业做什么的
  • 做淘宝需要知道什么网站吗大连谷歌seo
  • 学校网站怎么下载不了外链推广
  • 网站开发 群关键词歌曲歌词
  • SEO案例网站建设公司广州优化疫情防控举措
  • ppt精美模板专业搜索引擎seo公司
  • 免费个人主页注册seo优化推广工程师招聘
  • 网站建设保定网站推广方法
  • 淘宝联盟的购物网站怎么做黄页网络的推广网站有哪些类型
  • 石桥铺做网站最近大事件新闻
  • 网站建站发布平台网站建设关键词排名
  • 横岗做网站公司香飘飘奶茶软文
  • 汕头建站公司模板免费推广方式都有哪些
  • 如何建设一个web网站双桥seo排名优化培训
  • 深圳培训手机网站建设无锡百度竞价公司
  • 深圳做积分商城网站公司广州软文推广公司
  • 日本永久免费云服务器网站seo排名优化工具
  • 旅游网站建设导航栏怎么网站推广
  • 网站建设与网页设计入门网站seo推广招聘
  • 外贸独立网站做仿品crm网站