- 博客(18)
- 问答 (1)
- 收藏
- 关注
原创 背包问题
1 01背包http://acm.hdu.edu.cn/showproblem.php?pid=2602http://www.cnblogs.com/javawebsoa/archive/2013/07/19/3201314.htmlhttp://blog.csdn.net/libin56842/article/details/9338841#include #inc
2016-09-24 15:49:45 297
原创 AVL树(平衡二叉查找树)
定义:AVL树是带有平衡条件的二叉查找树。这个平衡条件必须容易保持,最简单的想法是要求左右子树具有相同高度旋转:为了使树保持平衡不平衡的可能性:单旋转双旋转 如何分辨单旋转还是双旋转并且进行旋转首先要看插入数字后,它破坏的是哪个节点的平衡,如果破坏了的节点和沿着插入节点方向的节点,这被插入的节点的值在这两个节点的值之间,则为双旋转,否则是单旋转,如图,加入了
2016-09-20 19:56:48 343
原创 AVL树
树的高度与深度的差别:http://blog.csdn.net/fanpei_moukoy/article/details/23828603
2016-09-19 19:48:41 243
原创 二叉查找树的操作
概念:使二叉树变成二叉查找树的性质是,对于树中的每个结点x,它的左子树中所有关键字值小于x的关键字值,而它的右子树中所有关键字的值大于x的关键字值先序输入typedef struct bitnode{ int data;//对于数字的输入注意对于每个数字之间的空格如果是字符的话就不用空格把每个字符分开 struct bitnode* lchild; struct
2016-09-18 21:07:43 331
原创 构建表达式树
方法输入后缀表达式,如果输入的是中缀表达式,则利用栈,转换成后缀表达式,然后检测每一个输入字符,如果操作数,则把该数的地址压入栈中,如果是操作符,则把栈的栈顶元素和栈顶元素的下一个元素出栈,分别为操作符的左子树和右子树,然后把该操作符的地址压入栈中,最后中序递归输出#include #include #include using namespace std;typedef struct
2016-09-18 18:19:12 976
原创 二叉树的层次遍历
层次遍历二叉树,关键要用到队列,父结点一出,就要判断子结点是否为空,非空则马上进入队列#include #include using namespace std;typedef struct bitnode{ char data; struct bitnode *lchild; struct bitnode *rchild;}bitnode,*bitree;
2016-09-17 17:23:05 232
原创 162-15
#include #include using namespace std;int leaf=0,node=0;typedef struct bitnode{ char data; struct bitnode* lchild; struct bitnode* rchild;}bitnode,*bitree;void create(bitree &bt){
2016-09-13 18:11:20 260
原创 树、森林和二叉树的转换
文章来自:http://www.cnblogs.com/zhuyf87/archive/2012/11/04/2753950.html
2016-09-13 17:53:44 184
原创 161-11
#include #include using namespace std;int l=0;char p[1000];typedef struct bitnode{ char data; struct bitnode* lchild; struct bitnode* rchild;}bitnode,*bitree;void create(bitree &bt
2016-09-13 17:37:32 186
原创 haffuman树
#include #include using namespace std;//哈夫曼树的存储表示typedef struct{ int weight; // 权值 int parent, lChild, rChild; // 双亲及左右孩子的下标}HTNode, *HuffmanTree;// 选择权值最小的两颗树void SelectMin(H
2016-09-08 20:59:01 668
原创 线索二叉树
线索二叉树方便了寻找前驱和后继//0 为link,1为thread#include #include using namespace std;typedef struct node{ char data; struct node* lchild; struct node* rchild; int ltag,rtag;}bitnode,*bitree;
2016-09-07 18:31:57 284
原创 二叉树
/*测试数据 ABD#G###CE##F##*/#include #include using namespace std;typedef struct node{ char data; struct node* lchild; struct node* rchild;}*bitree,bitnode;typedef struct qstack{
2016-09-05 22:34:22 304
原创 二叉树的各种遍历
#include #include using namespace std;typedef struct node{ char data; struct node* lchild; struct node* rchild;}*bitree,bitnode;typedef struct qstack{ bitree *base;//存储bitree指针
2016-09-05 18:38:14 264
原创 对于链表,栈,队列,树函数参数的理解(未完)
对于最近学习的链表,栈,队列,二叉树(基础)的函数参数有了更深的理解。对于这几个数据结构,可以采用静态,或者是链式存储和操作,但是它们函数的参数却是不一样的。对于一些链式存储和操作的,有3种方法来返回头指针1 在函数外新建头指针,然后函数返回头指针2 用二级指针3 用参数的引用(效果和二级指针一样)链表(静态):typedef struct list{ int
2016-09-05 18:34:39 331
原创 广义表头尾链表(未完)
#include #include #include #include #define MAX 225using namespace std;typedef unsigned char Sstring [MAX+1];typedef enum{ATOM,LIST}eleflag;typedef struct node{ eleflag tag; union
2016-09-03 15:34:12 571
原创 114-3
#include #include #define MAXSIZE 225using namespace std;typedef unsigned char SString[MAXSIZE + 1];//typdef unsigned char a[MAX_LEN]意思是定义类型unsigned char// [MAX_LEN]为a的形式void init(SString &T)//
2016-09-02 11:24:54 234
原创 KMP
#include #include #define MAX 225using namespace std;typedef unsigned char Sstring[MAX+1];void init(Sstring &s){ int i; char str[100]; cin>>str; for(i=1;str[i]!='\0';i++) {
2016-09-01 17:31:41 200
空空如也
c++自己创建类的一个问题
2017-07-04
TA创建的收藏夹 TA关注的收藏夹
TA关注的人