![](https://img-blog.csdnimg.cn/20201014180756757.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
算法
文章平均质量分 73
梦想之深邃
这个作者很懒,什么都没留下…
展开
-
已知入栈顺序,判断某一序列是否为其合法出栈序列!
代码: #include #include void Check(int a[],int b[],int n){ int * c; int i=0,j=0,k=0; c=(int *)malloc(sizeof(int)*n); while(i do{ c[k++]=a[i]; }while(a[i++]!=b[j]); for(int f=k-1;f>=0;f--){ i原创 2017-06-04 10:12:45 · 1027 阅读 · 0 评论 -
桶排序
数据结构实验之排序三:bucket sort Time Limit: 250MS Memory Limit: 65536KB Submit Statistic Discuss Problem Description 根据人口普查结果,知道目前淄博市大约500万人口,你的任务是帮助人口普查办公室按年龄递增的顺序输出每个年龄有多少人,其中不满1周岁的按0岁计算,1到2周岁原创 2017-12-16 11:48:29 · 178 阅读 · 0 评论 -
Hash-开放地址法
#include #define N 100005 int Check[N]; int main(){ int n,num; scanf("%d %d",&n,&num); for(int i=0;i<n;i++){ int index; scanf("%d",&index); Check[index]=1; } for(int j=0;j<num;j++){ int k原创 2017-12-16 11:04:24 · 601 阅读 · 0 评论 -
线性探测-Hash表的创建-查找
数据结构实验之查找七:线性之哈希表 Time Limit: 1000MS Memory Limit: 65536KB Submit Statistic Discuss Problem Description 根据给定的一系列整数关键字和素数p,用除留余数法定义hash函数H(Key)=Key%p,将关键字映射到长度为p的哈希表中,用线性探测法解决冲突。重复关键字放在h原创 2017-12-15 21:22:35 · 1034 阅读 · 0 评论 -
二叉树的深度和叶子节点数
int Deapth(Tree * root){//二叉树的深度 if(!root){ return 0; } int m=Deapth(root->Left); int n=Deapth(root->Right); return m>n?m+1:n+1; } int LeaveNum(Tree * root){//二叉树的叶子数 if(!root){ return 0; }原创 2017-12-13 18:24:30 · 2581 阅读 · 1 评论 -
堆排序-C语言实现
#include #include void Swap(int * a,int * b){ int t=*a; *a=*b; *b=t; } void AdjustHeap(int a[],int location,int n){ int key=a[location]; for(int i=2*location;i<n;i*=2){ if(i<n&&a[i]<a[i+1]) //找原创 2017-12-12 22:11:26 · 2454 阅读 · 2 评论 -
Dijkstra算法-最短路径-邻接矩阵表示
图结构练习——最短路径 Time Limit: 1000MS Memory Limit: 65536KB Submit Statistic Discuss Problem Description 给定一个带权无向图,求节点1到节点n的最短路径。 Input 输入包含多组数据,格式如下。 第一行包括两个整数n m,代表节点个数和边的个数。(n原创 2017-12-12 08:15:59 · 1076 阅读 · 0 评论 -
判断两颗二叉排序树是否相等
数据结构实验之查找一:二叉排序树 Time Limit: 400MS Memory Limit: 65536KB Submit Statistic Discuss Problem Description 对应给定的一个序列可以唯一确定一棵二叉排序树。然而,一棵给定的二叉排序树却可以由多种不同的序列得到。例如分别按照序列{3,1,4}和{3,4,1}插入初始为空的二叉排序树,原创 2017-12-11 17:07:04 · 753 阅读 · 0 评论 -
图的深度遍历-邻接链表表示
#include #include #define N 1005 typedef struct Link{ int data; struct Link * next; struct Link * fir; }Link; Link Pic[N]; int front=0; int rear=0; int Check[N]; int Queue[N]; void DFS(Link a[],int原创 2017-12-10 18:49:59 · 425 阅读 · 0 评论 -
图的广度遍历-邻接链表表示
#include #include #define N 1005 typedef struct Link{ int data; struct Link * next; struct Link * fir; }Link; Link Pic[N]; int front=0; int rear=0; int Check[N]; int Queue[N]; void BFS(Link a[],int原创 2017-12-10 18:47:47 · 439 阅读 · 0 评论 -
判断无向图图的连通性,邻接矩阵表示
数据结构实验之图论三:判断可达性 Time Limit: 1000MS Memory Limit: 65536KB Submit Statistic Discuss Problem Description 在古老的魔兽传说中,有两个军团,一个叫天灾,一个叫近卫。在他们所在的地域,有n个隘口,编号为1..n,某些隘口之间是有通道连接的。其中近卫军团在1号隘口,天灾军团在n号原创 2017-12-09 21:56:40 · 13301 阅读 · 0 评论 -
图的深度遍历和回溯
数据结构实验之图论四:迷宫探索 Time Limit: 1000MS Memory Limit: 65536KB Submit Statistic Discuss Problem Description 有一个地下迷宫,它的通道都是直的,而通道所有交叉点(包括通道的端点)上都有一盏灯和一个开关;请问如何从某个起点开始在迷宫中点亮所有的灯并回到起点? Input原创 2017-12-09 18:18:35 · 840 阅读 · 0 评论 -
基于邻接矩阵的广度优先遍历
数据结构实验之图论一:基于邻接矩阵的广度优先搜索遍历 Time Limit: 1000MS Memory Limit: 65536KB Submit Statistic Discuss Problem Description 给定一个无向连通图,顶点编号从0到n-1,用广度优先搜索(BFS)遍历,输出从某个顶点出发的遍历序列。(同一个结点的同层邻接点,节点编号小的优先遍历)原创 2017-12-09 17:14:10 · 4247 阅读 · 0 评论 -
Prim算法(普里姆算法)加点法-Prim算法
数据结构实验之图论六:村村通公路 Time Limit: 1000MS Memory Limit: 65536KB Submit Statistic Discuss Problem Description 当前农村公路建设正如火如荼的展开,某乡镇政府决定实现村村通公路,工程师现有各个村落之间的原始道路统计数据表,表中列出了各村之间可以建设公路的若干条道路的成本,你的任务是原创 2017-12-17 23:01:58 · 976 阅读 · 1 评论