数据结构高分笔记
数据结构高分笔记
爱幻想-hjyp
遇到坎就得迈过去
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
《数据结构高分笔记》树与二叉树
文章目录二叉树的递归遍历(前中后)计算树型的表达式二叉树的递归遍历(前中后)typedef struct BTNode{ char data; struct BTNode *lchild, *rchild;}BTNode;//previous ordervoid preorder(BTNode *p){ if(p == NULL) return ; visit(p); preorder(p->lchild); preorder(p原创 2020-07-23 19:15:23 · 235 阅读 · 0 评论 -
《数据结构高分笔记》栈和队列
目录顺序栈的操作链栈基本操作例3-1 判断括号是否匹配计算后缀表达式循环队列顺序栈的操作用top指针指向栈顶元素,初始化为-1;进栈时先移动指针再赋值;出栈时先取值再移动指针;const int maxn = 1000;int Stack[maxn], top = -1;//top指向栈顶元素,初始时没有元素,赋为-1int push(int x){ //if stack is full if(top == maxn - 1) return 1; Stack[++to原创 2020-07-15 23:02:47 · 392 阅读 · 3 评论 -
KMP算法
#include <iostream>#include <algorithm>#include <memory>#include <cstring>using namespace std;const int maxn = 1000;int mynext[maxn], nextval[maxn];//t = next[j]表明p[0,j]的前缀和后缀相等的末尾下标是t,即p[0,t]是完全匹配的//next[j]表示j+1位匹配失败但j往前的匹原创 2020-07-15 21:12:03 · 157 阅读 · 0 评论 -
《数据结构高分笔记》线性表
例题2-1 有序顺序表的插入,删除元素思路:先找到插入位置,然后将后面的元素向后移动一位,最后将目标元素赋值,注意长度的加一;#include <iostream>#include <algorithm>using namespace std;const int maxn = 1000;//顺序表的结构体定义typedef struct { int data[maxn]; int length;}Sqlist;//使用typedef定义结构体原创 2020-07-11 20:01:02 · 248 阅读 · 0 评论
分享