随笔分类 -  trie树

摘要:感动天感动地啊!这道题我提交了整整11次!Runtime Error(ACCESS_VIOLATION)。错的地方在代码里写吧。。主要还是trie树的各种方法没写熟。#include<stdio.h>#include<malloc.h>#include<string.h>#define MAXNUM 27typedef struct tnode{ int mark,count; tnode *next[MAXNUM]; char words[20]; }tnode;tnode *root;char result[20];void init(){ int i; 阅读全文
posted @ 2013-04-18 21:32 Yuki_i 阅读(180) 评论(0) 推荐(0)
摘要:找前缀个数。主要是理解trie树的含义吧,统计一个节点出现的次数就可以了。 1 #include<stdio.h> 2 #include<malloc.h> 3 #include<string.h> 4 #define MAXNUM 26 5 typedef struct tnode 6 { 7 int mark,count; 8 tnode *next[MAXNUM]; 9 10 }tnode;11 tnode *root;12 void init()13 {14 int i;15 root=(tnode*)malloc(sizeof(tnode)... 阅读全文
posted @ 2013-04-17 21:29 Yuki_i 阅读(154) 评论(0) 推荐(0)
摘要:---恢复内容开始--- trie树,我是设置了号码结束标志,在insert函数里做处理:如果在插入的过程中,一直没有开辟新的节点,说明新插入的这个号码是某个已经插入了的号码的前缀,输出“NO”。如果在插入的过程中,经过了结束标志,说明这个新插入的号码之前已经插入了前缀号码,同样的,输出“NO”。此外,都输出“YES”。 1 #include<stdio.h> 2 #include<malloc.h> 3 #include<string.h> 4 typedef struct tnode 5 { 6 int mark; 7 tnode *next[10]; 阅读全文
posted @ 2013-04-17 21:23 Yuki_i 阅读(173) 评论(0) 推荐(0)