- 1、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。。
- 2、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 3、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
- 4、该文档为VIP文档,如果想要下载,成为VIP会员后,下载免费。
- 5、成为VIP后,下载本文档将扣除1次下载权益。下载后,不支持退款、换文档。如有疑问请联系我们。
- 6、成为VIP后,您将拥有八大权益,权益包括:VIP文档下载权益、阅读免打扰、文档格式转换、高级专利检索、专属身份标志、高级客服、多端互通、版权登记。
- 7、VIP文档为合作方或网友上传,每下载1次, 网站将根据用户上传文档的质量评分、类型等,对文档贡献者给予高额补贴、流量扶持。如果你也想贡献VIP文档。上传文档
查看更多
AC自动机(基本应用多模式匹配)(AC automata (basic application multi-pattern matching))
AC自动机(基本应用多模式匹配)(AC automata (basic application multi-pattern matching))
Reference material:
Wang Yun (Maigo): construction, adaptation and improvement of Trie diagrams
=======================================================
Simple explanation:
Trie graph: a directed graph transformed from a trie tree. The goal is to use the simple and NB data structure of the trie tree.
AC automata: that is, a flexible use of trie diagrams, the use of KMP ideas added to the fail pointer. Efficient multimodal matching can be performed.
=======================================================
========================================
AC automata algorithm (Aho-Corasick Algorithm)
Take HDU 2222, Keywords, Search as an example:
Function: multi mode matching (dynamic structure)
Instructions:
1.trie_insert constructs a tire tree with root as its root (that is, keyword tree), and executes a pattern string at a time.
2.construct_ac_automaton (root) constructs the fail pointer of the trie tree with root as its root.
3.query (STR, root) queries how many string patterns are in the text string STR in the trie tree (pattern string Collection) with root as the root.
#include iostream
#include cstring
#include cstdio
Using namespace std;
Const int MAXN = 1000001; / / text on the maximum length of MAXN - 1
Const int MAXM = 51; / / word (string) the maximum length is MAXM - 1
Const, int, KEYSIZE = 26; //26 lowercase letters
Struct Node {
Node *fail; / / pointer failure
Node *next[KEYSIZE]; / / the number of son nodes
Int count; / / the number of words
Node () {
Fail = NULL;
Count = 0;
Memset (next, 0, sizeof (next));
}
*
~Node () {
Delete next;
Seemingly useless in hoj}, plus the memory does not decrease.
}*q[MAXN / 2]; / /?????? MAXM* the number of words
Char keyword[MAXM] (Pattern; / / word pattern string String)
Char str[MAXN]; / / text string
//trie==keyword, tree==a, set, of, patterns
Void trie_insert (char, *str, Node, *root)
{
Node *p = root;
Int i = 0;
While (str[i]) {
Int index = str[i] -a;
您可能关注的文档
- 藻类分离培养.doc
- 血液治疗46种.doc
- 西药冲刺呼吸系统.doc
- 西方部分的知识.doc
- 西药基本运作第六篇论文.doc
- 腹部职业检查.ppt
- 袖子结构设计.doc
- 西食谱.doc
- 解剖_6呼吸系统.doc
- 解剖 - 脊柱区域.doc
- AC面试,无领导小组面试(AC interview, no leading group interview).doc
- ad7705布线规则(Ad7705 wiring rules).doc
- ADC打法及重要注意事项(ADC method and important precautions).doc
- Adobe Audion消音教程(Adobe Audion abatting tutorial).doc
- ADOBE公司的发展史(ADOBE's history).doc
- A-Z加速学习法在学习型组织中的应用(The application of a-z accelerated learning method in learning organization).doc
- Adobe的数字为iPad的第一步数字内容的浏览器(Adobe's number is the browser for the first digital content of the iPad).doc
- Adodb.Stream介绍(Adodb. Stream is introduced).doc
- ADR(美国存托凭证).doc
- ADSL测速、加速、检测故障全解决(ADSL speed detection, acceleration and detection fault are all resolved).doc
最近下载
- 2025年广东省春季高考英语情景交际专项复习试题(含答案解析).docx VIP
- 新解读《GB_T 748-2023抗硫酸盐硅酸盐水泥》最新解读.pptx VIP
- 《GB∕T 29490-2023 企业知识产权合规管理体系 要求》解读与应用指导材料(雷泽佳编写2024A0).docx VIP
- 抗硫酸盐硅酸盐水泥.docx VIP
- 高级钳工培训课件.ppt
- 第四章三节 铁路集装箱运输.ppt VIP
- 现代市政学(第三版)教案.ppt
- 2024至2030年中国中试基地行业发展形势及前景规划分析报告.docx
- 《老年人健康管理实务》老年保健与管理专业全套教学课件.pptx
- 2025年广东省春季高考英语完形填空专项复习试题三(含答案解析).docx VIP
文档评论(0)