
数据结构
无知小学僧
努力就会有成果
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
二叉树先,中,后序非递归遍历
#include <iostream>#include <stdio.h>#include <stdlib.h>#define maxsize 10using namespace std;typedef struct BTNode{ char data; struct BTNode *lchild; struct BTNode *rch...原创 2018-08-11 20:12:10 · 151 阅读 · 0 评论 -
用带头节点的循环链表表示队列
#include <iostream>#include <stdio.h>#include <stdlib.h>using namespace std;typedef struct LNode{ int data; struct LNode *next;}LNode;void enqueue(LNode *&rear,int x)...原创 2018-08-02 19:27:47 · 2017 阅读 · 0 评论 -
循环队列两端都可进行插入删除 (队尾删除,对头插入)
#include <iostream>#include <stdio.h>#include <stdlib.h>#define maxsize 100using namespace std;typedef struct { int data[maxsize]; int front,rear;}squeue;int desqueue(sq...转载 2018-08-02 20:25:32 · 6606 阅读 · 0 评论 -
循环队列加入tag使front==rear用做队满条件
#include <iostream>#include <stdio.h>#include <stdlib.h>#define maxsize 100using namespace std;typedef struct { int data[maxsize]; int front,rear; int tag;}squeue;int ...原创 2018-08-02 20:45:39 · 3082 阅读 · 2 评论 -
二叉树从根到叶节点的每条路径
#include <iostream>#include <stdio.h>#include <stdlib.h>#define maxsize 10using namespace std;typedef struct BTNode{ char data; BTNode *lchild; BTNode *rchild;}BTNode;voi...原创 2018-08-17 21:41:10 · 740 阅读 · 3 评论 -
二叉树节点操作
#include <iostream>#include <stdio.h>#include <stdlib.h>#define maxsize 10using namespace std;typedef struct BTNode{ char data; BTNode *lchild; BTNode *rchild;}BTNode;voi...原创 2018-08-16 19:14:06 · 265 阅读 · 0 评论 -
增加指向双亲节点的指针parent,输出所有节点到根节点路径
#include <iostream>#include <stdio.h>#include <stdlib.h>#define maxsize 10using namespace std;typedef struct BTNode{ char data; BTNode *lchild; BTNode *rchild; BTN...原创 2018-08-16 19:45:55 · 1243 阅读 · 1 评论 -
满二叉树先序变中序
#include <iostream>#include <stdio.h>#include <stdlib.h>#define maxsize 10using namespace std;void change(int pre[],int l1,int r1,int *post,int l2,int r2){ if(l1<=r1) ...原创 2018-08-16 20:33:59 · 476 阅读 · 1 评论 -
求二叉树中值为x的节点的层号
#include <iostream>#include <stdio.h>#include <stdlib.h>#define maxsize 20using namespace std;typedef struct BTNode{ char data; BTNode *lchild; BTNode *rchild;}BTNode;typ...原创 2018-08-16 21:27:42 · 4181 阅读 · 0 评论 -
已知递增单链表A和B,求集合A和集合B的差集,保存在链表A中
算法思想:只需将链表A中共有的节点删除即可。定义指针p,q分别指向A,B的头结点,当A中元素小于B的时,p右移一位(B类似操作),值相等时,删除该节点,任一指针为空时停止循环代码:#include <iostream>#include <stdio.h>#include <stdlib.h>using namespace std;typede...原创 2020-06-02 21:31:24 · 1256 阅读 · 0 评论 -
小括号的匹配
#include <iostream>#include <stdio.h>#include <stdlib.h>#define maxsize 100using namespace std;int match(char A[],int n){ char stack[maxsize]; int count=0,top=-1,i; ...原创 2018-07-28 21:38:04 · 750 阅读 · 0 评论 -
求后缀式数值
#include <iostream>#include <stdio.h>#include <stdlib.h>#define maxsize 100using namespace std;int OP(int a,char op,int b){ if(op=='+') return a+b; if(op=='-') return...原创 2018-07-29 19:41:47 · 399 阅读 · 0 评论 -
用两个栈完成队列入队,出队,判空
#include <iostream>#include <stdio.h>#include <stdlib.h>#define maxsize 100using namespace std;typedef struct{ int elem[maxsize]; int top;}Sqstack;int Isempty(Sqsta...原创 2018-07-30 20:18:46 · 772 阅读 · 0 评论