自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+

让阳光照进心里

学习感悟+生活随笔

  • 博客(34)
  • 资源 (2)
  • 收藏
  • 关注

原创 欧拉回路算法C语言

<br />  这个东西,从研究到写完,用了18小时.是我太笨了吗?不过还好,总算是写出来了.<br />  收拾收拾,准备去那个城市考察一下.但愿带回真实的数据供我参考.<br />/* 9-32(a)-12-29-21.48.c -- 第九章第三十二题 */#include <stdio.h>#include <stdlib.h>#include "new_adjacenty_list.h"#include "rqueue.h"#define SIZE (12)int g

2010-12-31 12:35:00 4785

原创 寻找双连通分支C语言

<br />  话说这个东西,写了不下12小时.我坚持写完了,并且写对了.我很高兴.<br />  通过写这个东西,加强了对寻找割点问题的认识,从而认识,并明白了寻找双连通分支的过程.<br />  我想要说明的是,深度优先搜索,深度优先.从 (v, w) 开始的深度优先搜索, 在回到调用 (v, w) 的那次调用之前, (w, v) 已经被处理过.这保证一条边不会入栈两次.同时, 也同时可以避免已被作为背向边处理的 (v, w) 入栈.这都是通过 if (!Find_L (pli, w, index)) 

2010-12-27 01:02:00 1369

原创 栈数组实现实现文件C语言

<br />/* stack.c -- 栈实现文件 */#include <stdio.h>#include <stdlib.h>#include "stack.h"/* 接口函数定义 */int Initialize_S (Stack * const pstack, const int capacity){ if (capacity <= 0) return 0 ; *pstack = (struct stack *) malloc (sizeof (stru

2010-12-25 15:24:00 930

原创 栈数组实现头文件C语言

<br />  数组的栈,好久没有写了.这次的写,加深了理解,更加深刻地体会到例程中的技巧与实用.<br />/* stack.h -- 栈头文件 */#define EMPTY_TOP (-1)/* 数据类型定义 */typedef int Stack_Item ;typedef struct stack{ Stack_Item * array ; int capacity ; int top ;} * Stack ;/* 接口函数声明 */

2010-12-25 15:20:00 2243

原创 链表头文件C语言

<br />  因为眼前有个例程要使用链表,索性写了一个链表,纯洁的链表其实写得很少.写了一次,感觉又是受益匪浅.<br />/* linked_list.h -- 链表头文件 *//* 数据类型定义 */typedef int Linked_List_Item ;typedef struct linked_list_node{ Linked_List_Item v ; Linked_List_Item w ; struct linked_list_node * next

2010-12-25 15:17:00 6226

原创 链表实现文件C语言

<br />/* linked_list.c -- 链表实现文件 */#include <stdio.h>#include <stdlib.h>#include "linked_list.h"/* 局部函数声明 */static Linked_List_Node * Make_Node (const Linked_List_Item li1, const Linked_List_Item li2) ;/* 接口函数定义 */int Initialize_L (Li

2010-12-25 15:17:00 1711

原创 寻找强连通分支C语言

<br />  这东西,写了8小时.比较慢了.实现是一步一步地完成的.方法概述如下:<br />  1.对原图进行一次深度优先搜索,以后序对各顶点标号.<br />  2.将原图反转.<br />  3.在新图中,按照顶点标号从大到小的顺序对所有顶点逐个检查,并进行深度优先搜索.每一次调用深度优先搜索之后,下次调用时到调用结束阶段,声场的深度优先搜索树中的所有节点是强联通的.<br />  这个的原理书上说得我看不懂.我理解就是,新图中能够访问到的,在原图中以反向也能够访问到.于是所构成的集合是强连通的.至

2010-12-24 20:10:00 1102

原创 反转一个邻接表C语言

<br />  反转一个邻接表,没有考虑权值.是为另一个例程服务的一个函数.贴出来吧.<br />int Reverse_A (Adjacenty_List * const padj, const Hash_Table * const pht){ Name name ; Adjoin_To_Vertex * scan, * new_vertex, * temp_1, * * temp_2 ; int w, i, capacity = (*padj) -> capacity ; for

2010-12-24 19:58:00 799

原创 无向图割点搜索C语言

<br />  这个用来找到一个无向图中的所有割点,实现方式从简,例程正确.<br />  这个算法,对有向图是行不通的.<br />  通过一次深度优先搜索计算number[], 而后一趟后序遍历计算low[]来实现.<br />  说真的,我是基本不懂.代码还是写出来了,有点印象,日后好也有个参考.<br />/* 9-21-12-23-08.55.c -- 第九章第二十一题 */#include <stdio.h>#include "new_adjacenty_list.h"#defi

2010-12-23 10:17:00 1137

原创 最大生成树算法C语言

<br />  只是将算法的主例程边的权值改为异号的,即可完成这个算法.我的初衷是将最小堆改成最大堆.但事实证明,这是行不通的.贴代码.<br />/* 9-20-12-22-11.16.c -- 第九章第二十题 */#include <stdio.h>#include <stdlib.h>#include "binary_heap_for_kruskal.h"#include "disjiont_set.h"#define SIZE (10)int main (void)

2010-12-22 11:25:00 2143

原创 配合Kruskal算法不相交集合头文件C语言

<br />/* disjiont_set.h -- 不相交集合ADT头文件 */#define HEIGHT (0)#define OOS (1 << 31)/* 数据类型定义 */typedef int SetItem ;typedef SetItem SetType ;typedef SetItem * Disjiont ;/* 接口函数声明 *//* 操作: 按高度创建并初始化一个不相交集合 *//* 操作前: d 是一个不相交集合变量, ca

2010-12-19 23:20:00 841 1

原创 配合Kruskal算法不相交集合实现文件C语言

<br />/* disjiont_set.c -- 不相交集合实现文件 */#include <stdio.h>#include <stdlib.h>#include "disjiont_set.h"/* 接口函数定义 */int Initialize_D (Disjiont d, const int capacity){ int i ; if (capacity <= 0) return 0 ; d[0] = capacity ; for (i

2010-12-19 23:20:00 865

原创 配合Kruskal算法的二叉堆实现文件C语言

<br />/* binary_heap_for_kruskal.c -- 二叉堆实现文件 */#include <stdio.h>#include <stdlib.h>#include "binary_heap_for_kruskal.h"/* 局部函数声明 */static int Percolate_Up (const Binary_Heap * const pbh, const int index) ;static int Percolate_Down (const

2010-12-19 23:19:00 718

原创 配合Kruskal算法的二叉堆头文件C语言

<br />/* binary_heap_for_kruskal.h -- 二叉堆头文件 */#include "new_adjacenty_list.h"/* 数据类型定义 */typedef struct edge{ int v_hash_value ; int w_hash_value ; int weight ;} Edge ;typedef struct binary_heap{ Edge * heap ; int capacity ;

2010-12-19 23:18:00 851

原创 最小生成树Kruskal算法C语言

<br />/* 9-18(b)-12-19-00.49.c -- 第九章第十八题 */#include <stdio.h>#include <stdlib.h>#include "binary_heap_for_kruskal.h"#include "disjiont_set.h"#define SIZE (10)int main (void) ;void kruskal (const Adjacenty_List * const padj, const Hash_Ta

2010-12-19 23:14:00 2367

原创 最小生成树Prim算法C语言

<br />  本来在写kruskal算法,觉得不要让自己太透支了,毕竟年轻的本钱很容易挥霍光掉.昨天我就没脱衣服睡了一夜.<br />  还要5.30起来,而且一干就是一天呢.最近闹心工作的事,写了会代码,才感觉好多了.不然脑袋里老是这些,烦死了.<br />  我在忍耐,一直在忍耐.就是为了,我的忍耐能够换来周围环境的默默"支持",也就是,没人制止我.<br />  也许是我的忍耐不够,也许是我处事轻浮,总之,境况不好.无论如何,亲人我要顾及,自己也要顾及.实在到万不得已的时候,我还是会选择为了代码放弃

2010-12-19 01:36:00 1880

原创 一棵树流出的最大流问题C语言

<br />  确定一棵树流出的最大流,即树叶可以流入的最大流量的和,也就是整棵树流出的流量.<br />  树中每一个非叶节点的流出流量 = min (流入流量, 路径容量).<br />  知道了这些,自然的方式使用递归,就可求解出该问题.<br />  很遗憾,我是在看了答案之后才写出的这些.<br /><br />/* 9-12-12-15-15.53.c -- 第九章第十二题 *//* Pseudocode */FlowType FindMaxFlow (const Tree T, F

2010-12-15 16:23:00 936

原创 Dijkstra改进算法C语言

<br />/* 9-10(b)-12-13-20.26.c -- 第九章第十题(b) */#include <stdio.h>#include <stdlib.h>#include "binary_heap.h"int main (void) ;int new_dijkstra (const Adjacenty_List * padj, const Hash_Table * const pht, const int start) ;int main (void){

2010-12-13 22:20:00 1364

原创 邻接表生成模型头文件C语言

<br />/* new_adjacenty_list.h -- 邻接表头文件 */#include <stdarg.h>#include "hash.h"#define INFINITY (~(1 << 31))#define NEGATIVEINFINITY (-INFINITY - 1)/* 数据类型定义 */typedef struct adjoin_to_vertex{ int hash_value ; int cvw ; struct adjo

2010-12-13 00:34:00 867

原创 邻接表生成模型实现文件C语言

<br />/* new_adjacenty_list.c -- 邻接表实现文件 */#include <stdio.h>#include <stdlib.h>#include "new_adjacenty_list.h"/* 局部函数声明 */static Adjoin_To_Vertex * Make_Adjoin_To_Vertex (const Hash_Table * const pht, const Name name, const int cvw) ;/*

2010-12-13 00:34:00 899

原创 配合Dijkstra算法的二叉堆实现文件C语言

<br />/* binary_heap.c -- 二叉堆实现文件 */#include <stdio.h>#include <stdlib.h>#include "binary_heap.h"/* 局部函数声明 */static int Percolate_Up (const Binary_Heap * const pbh, const int index) ;static int Percolate_Down (const Binary_Heap * const pbh,

2010-12-13 00:33:00 1227

原创 配合Dijkstra算法的Hash表实现文件C语言

<br />/* hash.c -- 哈希表实现文件 */#include <stdio.h>#include <stdlib.h>#include "hash.h"/* 局部函数声明 */static int Get_A_Prime (const int number) ;static int Is_A_Prime (const int number) ;static int Square (const int i) ;/* 接口函数定义 */int H

2010-12-13 00:32:00 820

原创 配合Dijkstra算法的二叉堆头文件C语言

<br />/* binary_heap.h -- 二叉堆头文件 */#include "new_adjacenty_list.h"/* 数据类型定义 */typedef Vertex * Heap_Item ;typedef struct binary_heap{ Heap_Item * heap ; int capacity ; int current ;} * Binary_Heap ;/* 接口函数声明 *//* 操作: 创建并初始化一个二

2010-12-13 00:32:00 993

原创 配合Dijkstra算法的Hash表头文件C语言

<br />/* hash.h -- 哈希表头文件 */enum KindOfEntry {LEGITIMATE, EMPTY, DELETED} ;#define PRIME (7)#define FAILED (-2)#define NUL ('/0')#define FALSE (0)#define TRUE (1)/* 数据类型定义 */typedef char Name ;typedef struct cell{ Name name ;

2010-12-13 00:31:00 892

原创 单发点赋权最短路径C语言

<br />  话说,这个东西我写了前前后后4天有余, 光今天就写了10小时.终于写完了.感触颇多啊.!<br />  新的数据结构需要以前的数据结构结合使用,我沿着思路,进行设计,之后开始动笔,呵呵.开始写,就是.<br />  从Hash表,到邻接表,再到二叉堆,磕磕绊绊,自己写得比较着急,结果我还没有那么熟练,无法快速完成.能够完成,我就已经很高兴了.呵呵.<br />  很多概念,是随着写代码灵光起来的.写着写着,想起来书上原来有讲过,呵呵.<br />  对于Hash表和二叉堆的理解,总是在渐渐深

2010-12-13 00:30:00 947

原创 单发点无权最短路径C语言

/* adjacenty_list.c -- 邻接表实现文件 */#include #include #include "adjacenty_list.h"/* 局部函数声明 */Vertex * Make_Vertex (const Name vertex) ;/* 接口函数定义 */int CreateAdjacent_List (Adjacent_List * const padj, const int capacity){ int lenth_li

2010-12-10 21:22:00 866

原创 拓扑排序C语言

<br />  这个,主要体现的是思想.问题在一开始就被定义在了一道已知的习题上,所以并没有什么通用性.实现中,如果在栈中存储名字的同时存储索引,那么,将会省去很多次函数调用.而且,散列在我这个实现中也没有发挥作用,我会去实现的.<br />  基本的思路,就是这样,理解得还算不错,哈哈.<br />  可喜可贺的是,好几天没有写代码了.冷不丁一写,成功率出奇地高.和专心程度有关吗?加油吧.留给自己的时间不多了,每一天都要努力!<br />/* 9-3-12-07-20.06.c -- 第九章第三题 */

2010-12-08 01:17:00 1624

原创 栈头文件C语言

<br />/* Stack_ADT.h -- 栈模型头文件 *//* 数据类型定义 */typedef char Name ;typedef struct stack_node{ Name name ; struct stack_node * next ;} Stack_Node ;typedef Stack_Node * Stack ;/* 接口函数声明 *//* 操作: 初始化一个栈 *//* 操作前: pstack 指向一个栈 *//*

2010-12-08 01:01:00 6470

原创 栈实现文件C语言

<br />/* Stack_ADT.c -- 栈模型实现文件 */#include <stdio.h>#include <stdlib.h>#include "Stack_ADT.h"/* 局部函数声明 */ static Stack_Node * Make_Node (const Name * const panme) ;/* 接口函数定义 */int InitializeStack (Stack * const pstack){ *pstack =

2010-12-08 01:01:00 880

原创 将图读进邻接表实现文件C语言

<br />/* adjacenty_list.c -- 邻接表实现文件 */#include <stdio.h>#include <stdlib.h>#include "adjacenty_list.h"/* 局部函数声明 */Vertex * Make_Vertex (const Name vertex) ;/* 接口函数定义 */int CreateAdjacent_List (Adjacent_List * const padj, const int ca

2010-12-08 00:46:00 1320

原创 将图读进邻接表头文件C语言

/* adjacenty_list.h -- 邻接表头文件 */#include /* 数据类型定义 */typedef char Name ;typedef struct vertex{ Name name ; struct vertex * next ;} Vertex ;typedef struct adjacency_list{ Vertex * list ; int * indegree ; int capacity ;} * Adjac

2010-12-08 00:45:00 1201

原创 partial path compression.偏路径压缩C语言

<br />  不同于路径压缩,偏路径压缩使得访问路径上的节点整体向上移动.很好.<br />/* 8-14-12-03-00.30.c -- 第八章第十四题 */SetType Find (DisjiontSet gather, const Item item) ;SetType Find (DisjiontSet gather, const Item item){ Item temp, i, j ; if (gather[item] < 0) return item

2010-12-03 00:34:00 1051 3

原创 8-10-12-02-22.29.c

<br />  一个模拟函数,目的在于找到一对节点的最近公共祖先.实现思想是首先将树映射到一个数组中,跟节点值域为ROOT,其余节点值域为父节点索引,这样可以轻松找到父节点.于是,一个显而易见的模拟函数出现了.<br />/* 8-10-12-02-22.29.c -- 第八章第十题 *//* This is a model that can return a proximate communal parent betwen two node *//* First, map a tree to

2010-12-02 22:45:00 590

原创 8-7-12-01-22.47.c

<br />  模拟操作.菜单编辑得较简单.<br />  这个东西,很好.多了一手!<br />  内存段错误,哎.要小心写代码.认真写代码.<br />/* 8-7-12-01-22.47.c -- 第八章第七题 */#include <stdio.h>#include <stdlib.h>#define HEIGHT (0)#define SIZE (-1)#define OSS (-65536)typedef int Item ;typedef Item SetT

2010-12-02 01:09:00 756

For save__个人使用

AVL树. 刘洋拿来给我看的,我今天没有时间看了.先保存一下.回头来看.

2011-06-30

<<数据结构与算法分析-C语言描述>>编程练习

<<数据结构与算法分析-C语言描述>>编程练习. 课后习题的C语言实现.

2011-04-06

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除