随笔分类 - 树
已知先序中序求后序算法
摘要:// tree.cpp : Defines the entry point for the console application.//#include #include "string.h"typedef struct node{ char data; struct node *lchild,*rchild;} BinNode;typedef BinNode *BinTree;BinNode *CreateNode(char c){ BinNode *n1=new BinNode(); n1->data=c; n1->lchild=NULL; n1->r
阅读全文
HDU3724 ( Encoded Barcodes ) 字典树
摘要:字典树模板,v记录当前节点下单词数,注意与当前节点相同(到当前节点为止)的单词的统计p->v-sumall_vnext#include #include#include#include#includeusing namespace std;#define zero {0}typedef struct Trie{ int v; Trie *next[26];} Trie;char s[100100][100];Trie root;void createTrie(char *str){ int len = strlen(str); Trie *p = &root, *q; ...
阅读全文
二叉搜索树
摘要:对应HDU3791#include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std ;#ifdef DeBUG#define bug assert#else#define bug //#endif#define zero {0}#define INF 2000000000#define eps 1e-6typedef struct _Node //二叉树类,n保存变量{ int n;...
阅读全文