![](https://img-blog.csdnimg.cn/20201014180756925.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
数据结构
shayue111
这个作者很懒,什么都没留下…
展开
-
浙大mooc给出的调用qsort方法
/* 快速排序 - 直接调用库函数 *//*(前者小于后者输出1,前者大于后者输出-1)——是为降序*//*(前者小于后者输出-1,前者大于后者输出1)——是为升序*///助记方法:哪种情况下输出1,升降序便与该种情况吻合( 假设a在序列后,b在序列前) #include /*---------------简单整数排序---------------转载 2018-01-30 16:44:45 · 144 阅读 · 0 评论 -
基于浙大mooc给出的改进快排程序
void quick_sort(int *a,int left,int right){ if(right-left>=cutoff){ //cutoff于此处为区分快速排序和插入排序的阈值,数据较多时选择快排 int pivo=getpivot(a,left,right); int i=left+1,j=right-2,tmp; while原创 2018-01-30 16:39:34 · 172 阅读 · 0 评论 -
1004. Counting Leaves
1004. Counting LeavesA family hierarchy is usually presented by a pedigree tree. Your job is to count those family members who have no child.InputEach input file contains one test case. Each case star...原创 2018-02-08 15:36:59 · 138 阅读 · 0 评论 -
字符串哈希
将字符串转化成整数,比如是BOB类型的字符串int getID(char *a){ int id=0; for(int i=0;i<3;i++){ id=id*26+a[i]-'A'; } return id;}原创 2018-02-28 13:36:22 · 175 阅读 · 0 评论 -
PAT 1094. The Largest Generation
用邻接表存储图,然后BFS70~78这几行的代码必须放在while(rear!=front)这个循环的尾端,防止最大代位于末端时而由于front=rear已成立而跳出循环从而没有更新#include <stdio.h>#include <stdlib.h>#define max 100typedef struct ArcNode{ struct ArcNode *next;...原创 2018-02-23 09:25:44 · 127 阅读 · 0 评论 -
1064. Complete Binary Search Tree
//完全二叉搜索树,用数组存储,下标从1开始,左儿子为下标*2,右儿子为下标*2+1;//利用BST中序遍历的性质,将排好序的元素一一插入,最后按照下标遍历扫描一遍即可#include <stdio.h>#include <stdlib.h>int compare(const void*a,const void *b){ return (*(int*)a-*(int*)b)...原创 2018-02-24 09:24:01 · 112 阅读 · 0 评论 -
Dijkstra算法
应用Dijkstra算法能得到某一个点到其他点的最短路径。介绍输入数据:6 61 4 11 2 21 6 42 5 54 3 22 6 1算法简介有两个集合,S1-已经确定最短路径的点,S2-候选点每一轮while循环会从S2中挑出距离x最近的一个点作为real_x加入S1,并利用real_x来更新其他点到x的路径步骤演练以x = 1 为例,表格中蓝色表示已经加入S...原创 2018-11-20 11:38:16 · 119 阅读 · 0 评论