随笔分类 -  考研数据结构

1
摘要:数据结构定义 非递归前序 非递归中序 口诀: 栈空p空 停止循环 移最左下 出栈置右 非递归后序 口诀: 栈空p空 停止循环 移最左下 右存未访 压右入左 否则出栈 完整代码 阅读全文
posted @ 2018-08-04 23:53 TQCAI 阅读(502) 评论(0) 推荐(0)
摘要:1.中序线索二叉树 数据结构: 首先理解如何建立中序线索化二叉树。如果结点的左子树存在,lt为0 。不存在为1;右子树同理。直接对根节点进行中序遍历,在不存在的场合设置标志位和前驱、后继。 把二叉树看成中序遍历序列,序列的第一个结点(最左下结点)的前驱为NULL,最后一个结点(最右下结点)的后继为N 阅读全文
posted @ 2018-04-17 20:40 TQCAI 阅读(7938) 评论(1) 推荐(2)
摘要:测试数据:天勤2019 142页 代码: 1~3:递归先序、中序、后序: 这三种没什么难度,放在这凑个数 非递归栈实现: 4.非递归先序: 5.非递归中序: 6.非递归后序:(硬编码非抽象实现的两个栈真的很麻瓜啊……) 7.层序遍历: 完整代码: #include<iostream> #define 阅读全文
posted @ 2018-04-16 20:55 TQCAI 阅读(427) 评论(0) 推荐(0)
摘要:王道P38T20 主代码: 完整代码: #include <cstdio> #include <stdlib.h> using namespace std; typedef struct DNode{ int data,freq; struct DNode* next=NULL; struct DN 阅读全文
posted @ 2018-02-18 13:09 TQCAI 阅读(283) 评论(0) 推荐(0)
摘要:王道P38T19 代码: 完整代码: #include <cstdio> #include <stdlib.h> using namespace std; typedef struct LNode{ int data; struct LNode* next=NULL; LNode(int x=0){ 阅读全文
posted @ 2018-02-18 00:07 TQCAI 阅读(649) 评论(0) 推荐(0)
摘要:王道P39T17 主代码: 完整代码: #include <cstdio> #include <stdlib.h> using namespace std; typedef struct DNode{ int data; struct DNode* next=NULL; struct DNode* 阅读全文
posted @ 2018-02-17 19:12 TQCAI 阅读(898) 评论(0) 推荐(0)
摘要:王道P38T16 代码: 主代码: #include <cstdio> #include <stdlib.h> using namespace std; typedef struct LNode{ int data; struct LNode* next=NULL; LNode(int x=0){ 阅读全文
posted @ 2018-02-17 18:24 TQCAI 阅读(1223) 评论(0) 推荐(0)
摘要:王道P38T14 主代码: 完整代码: #include <cstdio> #include <stdlib.h> using namespace std; typedef struct LNode{ int data; struct LNode* next=NULL; LNode(){ } LNo 阅读全文
posted @ 2018-02-17 17:48 TQCAI 阅读(411) 评论(0) 推荐(0)
摘要:王道P38T13 主代码: 完整代码: #include <cstdio> #include <stdlib.h> using namespace std; typedef struct LNode{ int data; struct LNode* next=NULL; LNode(){ } LNo 阅读全文
posted @ 2018-02-17 16:26 TQCAI 阅读(1569) 评论(0) 推荐(0)
摘要:王道P37T12 主代码: 完整代码: #include <cstdio> #include <stdlib.h> using namespace std; typedef struct LNode{ int data; struct LNode* next=NULL; LNode(){ } LNo 阅读全文
posted @ 2018-02-17 15:53 TQCAI 阅读(359) 评论(0) 推荐(0)
摘要:OJ链接:https://www.patest.cn/contests/pat-a-practise/1119 我的分析过程:pat1119分析.pdf 参考博客:https://www.cnblogs.com/xiongmao-cpp/p/6498672.html 实现代码: 完整代码: #inc 阅读全文
posted @ 2018-02-02 12:28 TQCAI 阅读(365) 评论(0) 推荐(0)
摘要:使用的全局变量: 根据前序、中序生成后序: 根据后序、中序生成前序: 完整代码: #include <stdio.h> #include <memory.h> #include <math.h> #include <string> #include <vector> #include <set> # 阅读全文
posted @ 2018-02-01 21:24 TQCAI 阅读(336) 评论(0) 推荐(0)
摘要:王道P37 T5 所谓原地逆置,就是空间复杂度为O(1)的将链表反转。 实现函数: 完整代码: #include <cstdio> #include <stdlib.h> using namespace std; typedef struct LinkList{ int data; struct L 阅读全文
posted @ 2018-01-30 23:27 TQCAI 阅读(508) 评论(0) 推荐(0)
摘要:王道P37 T1 : 设计一个递归算法,删除不带头结点的单链表L中所有值为x的结点。 王道上的答案绝对是错的,我自己想了一个 函数主体 调用方法: 完整代码: #include <stdlib.h> #include <cstdio> using namespace std; typedef str 阅读全文
posted @ 2018-01-28 23:33 TQCAI 阅读(997) 评论(0) 推荐(1)
摘要:王道P18 T11 输入两个长度相同的升序数组,返回这两个数组合并后的中位数 C++代码: 完整代码: #include <cstdio> #include <memory.h> #include <cmath> #include <string> #include <vector> #includ 阅读全文
posted @ 2018-01-01 20:39 TQCAI 阅读(1216) 评论(0) 推荐(0)
摘要:王道 P18 T11 : 写的O(n)的代码: 阅读全文
posted @ 2017-12-26 16:05 TQCAI 阅读(375) 评论(0) 推荐(0)
摘要:王道 P18 T10 : 顺序表循环左移: 逆序函数: 实现代码: 效果:(循环左移两个单位) 阅读全文
posted @ 2017-12-26 15:04 TQCAI 阅读(297) 评论(0) 推荐(0)
摘要:C++代码: 效果: 阅读全文
posted @ 2017-12-26 13:59 TQCAI 阅读(615) 评论(0) 推荐(0)
摘要:1.二分查找某个元素 1)递归实现 2)非递归实现 2.二分查找范围元素 效果: 阅读全文
posted @ 2017-12-25 12:21 TQCAI 阅读(429) 评论(0) 推荐(0)
摘要:删除顺序表中的某个元素 实现1:(查找到与value相同的元素,将指针不断右移知道与value不同) C++代码: 注意点:记得使用while语句做判断,不然不能删除连续的value 实现效果: 仿王道伪代码: 王道P20 T3 实现2:(用辅助下标k记录与value不同的元素) C++代码: 实现 阅读全文
posted @ 2017-12-24 16:24 TQCAI 阅读(2955) 评论(0) 推荐(0)

1