![](https://img-blog.csdnimg.cn/20201014180756724.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
数据结构
文章平均质量分 69
哈哈哈猪在飞
这个作者很懒,什么都没留下…
展开
-
数据结构——堆栈(二)
堆栈(Stack)可以认为是具有一定约束的线性表,插入和删除操作都作用在一个称为栈顶(Top)的端点位置。原创 2021-03-30 10:27:55 · 182 阅读 · 0 评论 -
数据结构——队列(三)
队列(Queue)是一个有序线性表,但队列的插入和删除操作是分别在线性表的两个不同端点进行的。 操作集 Queue CreateQueue(int MaxSize) bool IsFull(Queue Q) bool AddQ(Queue Q, ElementType X) bool IsEmpty(Queue Q) ElementType DeleteQ(Queue Q) 1.队列的顺序存储实现 typedef int Position; typedef struct QNode *PtrToQNod原创 2021-03-30 10:27:31 · 265 阅读 · 1 评论 -
数据结构——线性表的定义与实现(一)
线性表的基本操作: List MakeEmpty() ElementType FindKth(List L, int i) Position Find(List L, ElementType X) bool Insert(List L, ElementType X, int i) bool Delete(List L, int i) int Length(List L)原创 2021-03-30 10:26:17 · 351 阅读 · 0 评论 -
01-复杂度1 最大子列和问题
01-复杂度1 最大子列和问题 #include <stdio.h> int Max3(int a, int b, int c){ return a>b ? a>c ? a : c : b>c ? b :c; } int DivideAndConquer(int List[], int left, int right){ int MaxLeftSum, MaxRightSum; /*存放左右子问题的解*/ int MaxLeftBorder原创 2021-02-23 21:23:16 · 52 阅读 · 0 评论 -
06-图2 Saving James Bond - Easy Version
14 20 25 -15 -25 28 8 49 29 15 -35 -2 5 28 27 -29 -8 -28 -20 -35 -25 -20 -13 29 -30 15 -35 40 12 12 4 13 -12 12 12 12 -12 -12 12 -12 假设这个湖是一个100乘100平方的湖。假设湖的中心位于(0,0),东北角位于(50,50)。中心岛是一个直径为15的圆盘,中心位于(0,0)。许多鳄鱼在湖里的不同位置。考虑到每只鳄鱼的坐标和詹姆斯能跳的距离,你必须告诉他他是否能逃脱。.原创 2020-08-20 20:56:21 · 108 阅读 · 0 评论 -
01-复杂度2 Maximum Subsequence Sum
10 -10 1 2 3 4 -5 -23 3 7 -21 1.代码一 #include<stdio.h> #define MaxSize 10000 #define INF 0x3f3f3f3f void MaxSubseqSum1(int A[], int N){ int ThisSum, MaxSum = -INF; int flag=0,i, j, k; int first, last; for(i=0; i<N; i++){ if(A[.原创 2020-08-15 22:58:43 · 248 阅读 · 0 评论 -
05-树7 堆中的路径
5 3 46 23 26 24 10 5 4 3 1.代码 #include<stdio.h> #include<stdlib.h> #define MaxSize 1000 typedef int ElementType; typedef struct HNode *Heap; /* 堆的类型定义 */ struct HNode { ElementType *Data; /* 存储元素的数组 */ int Size; /* 堆中当前元素个数 .原创 2020-08-14 22:30:45 · 145 阅读 · 0 评论 -
04-树6 Complete Binary Search Tree
10 1 2 3 4 5 6 7 8 9 0 对于这个问题: 首先,确定树的表示法: 链表 VS数组 在确定数据结构时,通常与我们要做的事情有关联。在这个题目中有两个基本的操作:填写数字(某种遍历)、层序遍历(输出)——都是遍历,就遍历操作而言,使用链表或者数组在时间上都差不多 在空间上,对于此题涉及完全二叉树-,没有一个元素的空间是浪费的----使用数组合算;而且最后, 使用链表的话也可以,借助队列可以实现;但是用数组的话,本来就是按照层序遍历存储的,所以----使用数组完胜 数组的优点:不.原创 2020-08-13 14:47:37 · 106 阅读 · 0 评论 -
04-树5 Root of AVL Tree
5 88 70 61 96 120 7 88 70 61 96 120 90 65 1.代码 #include<stdio.h> #include<stdlib.h> typedef int ElementType; typedef struct AVLNode * Position; typedef Position AVLTree; struct AVLNode{ ElementType Data; AVLTree Left; AVLTree Right; ..原创 2020-08-10 23:03:25 · 80 阅读 · 0 评论 -
07-图4 哈利·波特的考试
1.代码 #include<stdio.h> #define INFINITY 65535 #define MaxVertexNum 100 typedef int Vertex; typedef int WeightType; typedef struct ENode * PtrToENode; struct ENode{ Vertex V1; Vertex V2; WeightType Weight; }; typedef PtrToENode Edge; typedef stru原创 2020-08-07 22:22:05 · 130 阅读 · 0 评论 -
03-树1 树的同构
题目表述 给定两棵树T1和T2。如果T1可以通过若干次左右孩子互换就变成T2,则我们称两棵树是“同构”的。例如图1给出的两棵树就是同构的,因为我们把其中一棵树的结点A、B、G的左右孩子互换后,就得到另外一棵树。而图2就不是同构的。 图1 图2 现给定两棵树,请你判断它们是否是同构的。 输入格式: 输入给出2棵二叉树树的信息。对于每棵树,首先在一行中给出一个非负整数N (≤10),即该树的结点数(此时假设结点从0到N−1编号);随后N行,第i行对应编号第i个结点,给出该结点中存储的1个英文大写字母、其左孩原创 2020-08-05 17:46:37 · 135 阅读 · 0 评论 -
02-线性结构1 两个有序链表序列的合并
所有题目来自陈越、何钦铭老师的数据结构课程 1. 理论基础 2. 算法实战 01-复杂度1 最大子列和问题 #include <stdio.h> int Max3(int a, int b, int c){ return a>b ? a>c ? a : c : b>c ? b :c; } int DivideAndConquer(int List[], int left, int right){ int MaxLeftSum, MaxRightSum;原创 2020-07-30 22:20:07 · 79 阅读 · 0 评论 -
02-线性结构2 一元多项式的乘法与加法运算
typedef struct PolyNode *Polynomial; struct Poly{ int coef; int expon; Polynomial link; }; void Attach(int c, int e, Polynomial *pRear){ Polynomial P; P = (Polynomial)malloc(sizeof(struct PolyNode)); P->coef = c; P-.原创 2020-07-30 22:18:50 · 148 阅读 · 0 评论