MOOC数据结构
文章平均质量分 92
1
是忧伤还是快乐
这个作者很懒,什么都没留下…
展开
-
堆排序
#include<cstdio> #include<algorithm> using namespace std; void PercDown( int A[], int p, int N ) { /* 将N个元素的数组中以A[p]为根的子堆调整为最大堆 */ int Parent, Child; int X; X = A[p]; /* 取出根结点存放的值 */ for( Parent=p; (Parent*2+1)<N; Paren原创 2020-05-27 17:01:19 · 123 阅读 · 0 评论 -
7-4 是否同一棵二叉搜索树
方法还是固定的建树 然后用vector存放遍历的结果 利用vector可以直接判断是否相等的好处 判断遍历结果是否一样。 #include<vector> #include<cstdio> #include<stdlib.h> using namespace std; typedef struct node{ struct node* left; struct node*right; int data; }*bintree; vector<int>b..原创 2020-05-26 20:57:27 · 144 阅读 · 0 评论 -
08-图8 How Long Does It Take
#include<cstdio> #include<algorithm> #include<queue> using namespace std; const int maxn = 550; const int INF = 1000000000; int n,m; int G[maxn][maxn]; int earlist[maxn] = {0}; int indegree[maxn] = {0}; void tporder(){ int num = 0; q...原创 2020-05-23 21:40:24 · 132 阅读 · 0 评论 -
04-树5 Root of AVL Tree
#include<cstdio> #include<algorithm> #include<stdlib.h> using namespace std; struct node{ struct node*left; struct node*right; int height; int data; }; typedef struct node*AVLTree; int getheight(AVLTree T) { if(T==NULL) return 0;...原创 2020-05-23 21:37:26 · 86 阅读 · 0 评论 -
05-树7 堆中的路径
#include<cstdio> #include<stdlib.h> struct node{ int *data; int size; }; typedef struct node *minheap; minheap create(int maxsize) { minheap h = (minheap)malloc(sizeof(struct node)); h->data = (int*)malloc(sizeof(int)*(maxsize+1)); h-..原创 2020-05-23 21:33:46 · 99 阅读 · 0 评论 -
03-树1 树的同构
#include<cstdio> using namespace std; struct node{ int left; int right; int root; char id; }tree[20],bt[20]; int main() { int n; char l,r; char c; scanf("%d",&n); for(int i=0;i<n;i++){ tree[i].left = -1; tree[i].right = -1; tree原创 2020-05-11 15:36:32 · 78 阅读 · 0 评论 -
03-树2 List Leaves
本题要求的是叶结点 就是度为0的结点 并且要按照上下 左右的顺序输出。 一 首先要找到根节点 求根节点的方法就是找到那个没有其他结点的左右子结点能够指到的位置 那个位置就是根节点。 树的顺序存储结构的具体方法是多加一个root的变量 struct node{ int left; int right; int root; }tree[maxsize]; 首先给所有的root赋值令其为-1; 然后在输入数据的时候令tree[子节点.left] = 0 tree[子节点.right] = 0; 所..原创 2020-05-09 22:08:08 · 132 阅读 · 0 评论