- 博客(7)
- 资源 (5)
- 收藏
- 关注
原创 字典树Trie_Tree
#include#includeusing namespace std;struct Trie_Tree{ char *str; int nFlag; Trie_Tree *arr[26];};Trie_Tree *CreateNode(){ Trie_Tree *temp = new Trie_Tree; memset(temp,0,4*
2016-01-25 20:29:07 451
原创 KMP
#include#includeusing namespace std;int *GetNext(char *str){ if(str == NULL) { return NULL; } int *next = new int[strlen(str)]; int i = 1; int ID = i-1; next
2016-01-25 20:23:01 357
原创 二叉排序树的第k个结点
//采用中序遍历的方式,第k个节点为有顺序的Tree *Find_Node(Tree *root,int &k){ Tree *temp = NULL; if(root->pLeft != NULL)//如果当前结点的 pLeft 不为空,则向左移动 { temp = Find_Node(root->pLeft,k); } if(tem
2016-01-24 17:43:54 1345
原创 判断二叉树的子结构
bool DoFind(Tree *root1,Tree *root2){ if(root2 == NULL)//直到找到 要查找的 子树 到了 最底下 为空 说明 此时 一直是正确的 { return true; } if(root1 == NULL)//说明此时 root2并不等于空 (上面两个条件不能写反) (root2 != NUL
2016-01-24 17:42:45 653
原创 二叉搜索树的后序遍历序列序列判断是否是二叉搜索树
class Solution {public: bool VerifySquenceOfBST(vector sequence) { if(sequence.empty() == true) { return false; } return PanDuanTree(sequence,0,sequenc
2016-01-24 17:41:40 462
原创 LCA树两个节点最低公共祖先
#include#includeusing namespace std;struct Tree{ Tree *pLeft; Tree *pRight; int nValue;};bool FindPath(Tree *root,int nFindValue,vector &vec){ if(root == NULL) { r
2016-01-24 17:40:25 570
原创 树的打印方式
Z行打印二叉树void Z_Print_Tree(Tree *root){ if(root == NULL) { return ; } stack sta[2]; //两个栈 sta[0]是放 奇数层的 数字 sta[1] 放偶数层的数字 sta[0].push(root); int ceng = 1;//当前打印的
2016-01-24 17:38:38 989
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人