- 浏览: 92678 次
- 性别:
- 来自: 广州
最新评论
文章列表
梳排序(Comb sort)是一种由Wlodzimierz Dobosiewicz于1980年所发明的不稳定排序算法,并由Stephen Lacey和Richard Box于1991年四月号的Byte杂志中推广。梳排序是改良自泡沫排序和快速排序,其要旨在于消除乌龟,亦即在阵列尾部的小数值,这 ...
/* c7-4.h 无向图的邻接多重表存储表示 */
#define MAX_VERTEX_NUM 20
typedef enum{unvisited,visited}VisitIf;
typedef struct EBox
{
VisitIf mark; /* 访问标记 */
int ivex,jvex; /* 该边依附的两个顶点的位置 */
struct EBox *ilink,*jlink; /* 分别指向依附这两个顶点的下一条边 */
InfoType *info; /* 该边信息指针 */
}EBox;
typedef st ...
/* c7-3.h 有向图的十字链表存储表示 */
#define MAX_VERTEX_NUM 20
typedef struct ArcBox
{
int tailvex,headvex; /* 该弧的尾和头顶点的位置 */
struct ArcBox *hlink,*tlink; /* 分别为弧头相同和弧尾相同的弧的链域 */
InfoType *info; /* 该弧相关信息的指针(可无) */
}ArcBox; /* 弧结点 */
typedef struct
{
VertexType data;
ArcBox *f ...
/* c7-2.h 图的邻接表存储表示 */
#define MAX_VERTEX_NUM 20
typedef enum{DG,DN,AG,AN}GraphKind; /* {有向图,有向网,无向图,无向网} */
typedef struct ArcNode
{
int adjvex; /* 该弧所指向的顶点的位置 */
struct ArcNode *nextarc; /* 指向下一条弧的指针 */
InfoType *info; /* 网的权值指针) */
}ArcNode; /* 表结点 */
typedef struct
{
...
/* algo7-1.c 调用算法7.7、7.8 */
#include"c1.h"
#define MAX_NAME 2 /* 顶点字符串的最大长度+1 */
typedef char ElemType[MAX_NAME];
typedef ElemType TElemType;
#include"c6-5.h"
typedef int InfoType;
typedef char VertexType[MAX_NAME];
#include"c7 ...
/* c6-5.h 树的二叉链表(孩子-兄弟)存储表示 */
typedef struct CSNode
{
TElemType data;
struct CSNode *firstchild,*nextsibling;
}CSNode,*CSTree;
/* bo6-5.c 树的二叉链表(孩子-兄弟)存储(存储结构由c6-5.h定义)的基本操作(17个) */
Status InitTree(CSTree *T)
{ /* 操作结果: 构造空树T */
*T=NULL;
return OK;
}
void De ...
/* c6-4.h 树的双亲表存储表示 */
#define MAX_TREE_SIZE 100
typedef struct
{
TElemType data;
int parent; /* 双亲位置域 */
} PTNode;
typedef struct
{
PTNode nodes[MAX_TREE_SIZE];
int n; /* 结点数 */
} PTree;
/* bo6-4.c 树的双亲表存储(存储结构由c6-4.h定义)的基本操作(14个) */
Status InitTree(PTree *T ...
/* c6-3.h 二叉树的二叉线索存储表示 */
typedef enum{Link,Thread}PointerTag; /* Link(0):指针,Thread(1):线索 */
typedef struct BiThrNode
{
TElemType data;
struct BiThrNode *lchild,*rchild; /* 左右孩子指针 */
PointerTag LTag,RTag; /* 左右标志 */
}BiThrNode,*BiThrTree;
/* bo6-3.c 二叉树的二叉线索存储(存储结构由c6-3. ...
/* c6-2.h 二叉树的二叉链表存储表示 */
typedef struct BiTNode
{
TElemType data;
struct BiTNode *lchild,*rchild; /* 左右孩子指针 */
}BiTNode,*BiTree;
/* bo6-2.c 二叉树的二叉链表存储(存储结构由c6-2.h定义)的基本操作(22个) */
Status InitBiTree(BiTree *T)
{ /* 操作结果: 构造空二叉树T */
*T=NULL;
return OK;
}
void De ...
/* c6-1.h 二叉树的顺序存储表示 */
#define MAX_TREE_SIZE 100 /* 二叉树的最大结点数 */
typedef TElemType SqBiTree[MAX_TREE_SIZE]; /* 0号单元存储根结点 */
typedef struct
{
int level,order; /* 结点的层,本层序号(按满二叉树计算) */
}position;
/* bo6-1.c 二叉树的顺序存储(存储结构由c6-1.h定义)的基本操作(23个) */
Status InitBiTree(SqBiTree T)
...
/* c4-3.h 串的块链存储表示 */
#define CHUNKSIZE 4 /* 可由用户定义的块大小 */
typedef struct Chunk
{
char ch[CHUNKSIZE];
struct Chunk *next;
}Chunk;
typedef struct
{
Chunk *head,*tail; /* 串的头和尾指针 */
int curlen; /* 串的当前长度 */
}LString;
/* bo4-3.c 串采用块链存储结构(由c4-3.h定义)的基本操作(16个) */
...
/* c4-2.h 串的堆分配存储 */
typedef struct
{
char *ch; /* 若是非空串,则按串长分配存储区,否则ch为NULL */
int length; /* 串长度 */
}HString;
/* bo4-2.c 串采用堆分配存储结构(由c4-2.h定义)的基本操作(15个) */
/* 包括算法4.1、4.4 ...
/* c4-1.h 串的定长顺序存储表示 */
#define MAXSTRLEN 40 /* 用户可在255以内定义最大串长(1个字节) */
typedef char SString[MAXSTRLEN+1]; /* 0号单元存放串的长度 */
/* bo4-1.c 串采用定长顺序存储结构(由c4-1.h定义)的基本操作(14个) */
/* SString是数组,故不需引用类型。此基本操作包括算法4.2,4.3,4.5 */
Status StrAssign(SString T,char *chars)
{ /* 生成一个其值等于chars的串T * ...
/* c3-3.h 队列的顺序存储结构(可用于循环队列和非循环队列) */
#define MAXQSIZE 5 /* 最大队列长度(对于循环队列,最大队列长度要减1) */
typedef struct
{
QElemType *base; /* 初始化的动态分配存储空间 */
int front; /* 头指针,若队列不空,指向队列头元素 */
int rear; /* 尾指针,若队列不空,指向队列尾元素的下一个位置 */
}SqQueue;
/* bo3-4.c 顺序队列(非循环,存储结构由c3-3.h定义)的基本操作(9个) * ...
/* c3-2.h 单链队列--队列的链式存储结构 */
typedef struct QNode
{
QElemType data;
struct QNode *next;
}QNode,*QueuePtr;
typedef struct
{
QueuePtr front,rear; /* 队头、队尾指针 */
}LinkQueue;
/* bo3-2.c 链队列(存储结构由c3-2.h定义)的基本操作(9个) */
Status InitQueue(LinkQueue *Q)
{ /* 构造一个空队列Q */
...