![](https://img-blog.csdnimg.cn/20201014180756927.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
中国大学MOOC-陈越、何钦铭-数据结构
二狗子的天下
这个作者很懒,什么都没留下…
展开
-
进阶实验4-3.5 哈夫曼编码 (30 分)
仅供参考#include <iostream>#include <cstdio>#include <queue>#include <string>#include <map>using namespace std;const int maxn=10002;int N;priority_queue<int,vector<int>,greater<int> > q;struct node{原创 2021-09-04 22:28:27 · 191 阅读 · 0 评论 -
进阶实验4-3.4 笛卡尔树 (25 分)
实验书后没找到读者验证码,本程序仅在本地验证#include <cstdio>using namespace std;const int maxn=1010;struct node{ int k1,k2,left,right;}Tree[maxn];int N;bool isBST(int root){ if(root==-1) return true; bool f1,f2; f1=f2=true; if(Tree[root].left原创 2021-09-04 09:48:33 · 115 阅读 · 0 评论 -
03-树2 List Leaves
思路:通过队列进行数据处理。#include <stdio.h>#include <stdlib.h>#define Maxsize 10typedef struct tree* Tree;typedef struct node* Node;struct node{ int left; int right;};struct tree{ int head; Node TREE;};Tree Read();void Find(Tree A);int原创 2020-07-03 20:44:50 · 63 阅读 · 0 评论 -
03-树1 树的同构
#include <stdio.h>#include <stdlib.h>#define Null -1typedef struct tree* Tree;typedef struct node* Node;struct tree{ int head; Node TREE;};struct node{ char Letter; int left; int Right;};Tree Read(int N);int IF(Tree A, Tree B);原创 2020-07-02 23:32:43 · 117 阅读 · 0 评论 -
01-复杂度2 Maximum Subsequence Sum
做这道题的时候有点头昏脑胀,代码可能有的地方比较多余,望谅解。#include <stdio.h>int main(int argc, char *argv[]) { int i,ofirst,last,nfirst,K,n,sum=0,move=0,flag=1,flag2=1,extremeF,extremeL,cnt=0; scanf("%d",&K); for(i=0;i<K;i++){ scanf("%d",&n); move+=n;原创 2020-06-29 18:21:19 · 82 阅读 · 0 评论 -
02-线性结构4 Pop Sequence
**## 堆栈模拟**思路:做堆栈去模拟目标序列(即带检查序列)的产生。1.建立两个堆栈,一个为输入stack,提供输入值;一个为检查stack,负责检验目标值(即读入值);2.判断第一个是否大于stack的容量,是则继续,否则不断push直到目标值为止,并抛出目标值;3.开始进入循环,当两个stack都空时为止,循环中对每一个读进来的目标值进行一些分类;4.释放空间,返回1;#include <stdio.h>#include <stdlib.h>原创 2020-06-29 14:51:13 · 191 阅读 · 0 评论 -
Reversing Linked List
下面展示一些 内联代码片。// A code blockvar foo = 'bar';#include <stdio.h>#include <stdlib.h>#define ElementType int#define Maxsize 100000typedef struct node Node;typedef struct list* List;struct node{ ElementType Data; int Next;};struct lis原创 2020-06-27 11:20:20 · 68 阅读 · 0 评论