All DataStructure

/*
 * all structure difinition 
 */

/* 顺序表 */
typedef struct {
	ELEM_TYPE data[100];
	int length;
} sqlist;

/* 单链表 */
typedef struct lnode {
	ELEM_TYPE data;
	struct lnode *next;
} lnode, *linklist;

/* 双链表 */
typedef struct dulnode {
	ELEM_TYPE data;
	struct dulnode *prior;
	struct dulnode *next;
} dulnode, dulinklist;

/* 静态链表 */
typedef struct {
	ELEM_TYPE data;
	int cur;	/* simulate pointer */
	
} component, slinklist[MAXSIZE];

/* 顺序栈 */
typedef struct {
	ELEM_TYPE data[MAXSTACK];
	int top;
} sqstack;

/* 顺序循环队列 */
typedef struct {
	ELEM_TYPE data[SEQSIZE];
	int front;
	int rear;
} sqQunue;			/* 注意判断队列空,满 */


/* 链式队列(不需要循环了) */
typedef struct qnode {		/* 节点定义 */
	ELEM_TYPE data;
	struct qnode *next;
} Qnode, *Qlink;
typedef struct {		/* 关系定义 */
	Qlink front;
	Qlink rear;
} *linkqueue;

/* 数组:矩阵压缩存储 */
/* 1.三元组 */
typedef struct {		/* 节点存储 */
	int i,j;		/* 矩阵坐标 */
	ELEM_TYPE data;
} Triple;
typedef struct {
	Triple data[MAXSIZE];
	int mu, nu, tu;		/* 未压缩的行,列,非零元 */
} TSMatrix;			/* 关系定义 */
/* 2.行逻辑链接的顺序表 */
typedef struct {
	int i,j;
	ELEM_TYPE data;
} Triple;
typedef struct {
	Triple data[MAXSIZE];
	int rpos[MAXRC];	/* 每行第一个非0元,记录data数组中的下标号 */
	int mu, nu, tu;
} RLSMatrix;
/* 3.十字链表 */
typedef struct OLnode{		/* 节点 */
	int i,j;
	ELEM_TYPE data;
	struct OLnode *right, *down;
}OLNode, *OLink;
typedef struct {		/* 关系 */
	OLink *rhead, *chead;	/* 第1行,第1列头指针 */
	int mu,nu,tu;
} CrossList;

/* 树的双亲表示法 */
typedef struct PTNode {
	ELEM_TYPE data;
	int parent;
} PT;
typedef struct {
	PT nodes[MAX_TREE_SIZE];
	int r,n;		/* 根节点和节点总数 */
} PTree;
/* 树的孩子链表 表示法 */
typedef struct CTNode {		/* 关系 */
	int child;		/* 在数组中的下标 */
	struct CTNode *next;

} *ChildPtr;
typedef struct CTParent {	/* 双亲节点 */
	ELEM_TYPE data;
	ChildPtr firstchild;
} CTParent;
typedef struct {		/* 树结构 */
	CTParent nodes[MAX_NODE_SIZE];
	int n,r;		/* 节点总数和根位置 */
} CTree;
/* 树的孩子兄弟 表示法 */
typedef struct CSNode {
	ELEM_TYPE data;
	struct CSNode *firstchild, *nextsibling;	/* 左孩子,右兄弟 */
} CSNode, *CSTree;
/* 二叉树,二叉链表 */
typedef struct BiTNode {
	ELEM_TYPE data;
	struct BiTNode *lchild, *rchild;
} BiTNode, *BiTree;
/* 二叉树, 三叉链表 */
typedef struct BTTNode {
	ELEM_TYPE data;
	struct BTTNode *lchild, *rchild, *parent;
} BTTNode, *BTTNode;

/* 图 数组邻接矩阵 */
typedef struct ArcCell {	/* 边的结构 */
	VRType arcs;		/* 相连 1, 不相连 0*/
	InfoType *info;		/* 边本身可能的信息 */
} ArcCell, AdjMatrix[MAX_VERTEX_NUM][MAX_VER_TEX_NUM];
typedef struct {				/* 图的结构 */
	VertexType vex[MAX_VERTEX_NUM];		/* 本身顶点存储的信息 */
	AdjMatrix arcs;				/* 顶点之间关系 */
	int vexnum, arcnum;			/* 顶点数和弧数 */
	GraphKind kind;				/* 图的种类标志 */
} MGraph;
/* 图 邻接表 存储表示*/
typedef struct ArcNode {			/* 存储边的情况 */
	int adjvex;				/* 指示顶点在该顶点数组中的下标 */
	struct ArcNode *nextarc;		/* 跟此顶点相连的边 */
	Infotype *info;				/* 记录弧本身的信息,如权值 */
} ArcNode;
typedef struc VNode {				/* 顶点结构 */
	VertexType data;			/* 顶点信息 */
	ArcNode *firstarc;			/* 第一条弧 */
} VNode, AdjList[MAX_VERTEX_NUM];
typedef struct {				/* 图的结构 */
	AdjList vertices;			/* 图中顶点 */
	int vexnum, arcnum;			/* 顶点数和弧数 */
	in kind;				/* 图的标志 */
} ALGraph;
/* 有向图 十字链表 表示法 */
typedef struct Arcbox {				/* 弧的存储 */
	int tailvex, headvex;			/* 弧头, 弧尾节点在顶点数组中的下标 */
	struct Arcbox *hlink, *tlink;		/* 弧头,弧尾相同的链域 */
	InfoType *info;				/* 弧本身信息 */
} Arcbox;
typedef struct VexNode {			/* 顶点存储 */
	VertexType data;			/* 顶点信息 */
	Arcbox *firstin, *firstout;		/* 第一个入弧,第一个出弧 */
} VexNode;
typedef struct {				/* 图的存储 */
	VexNode xlist[MAX_VERTEX_NUM];		/* 顶点数组 */
	int vexnum, arcnum;			/* 顶点数,弧数 */
} OLGraph;
/* 无向图 邻接多重表 */
typedef struct EBox { 				/* 弧的存储 */
	VisitIf	mark;				/* 标记是否被访问过 */
	int ivex, jvex;				/* 依附此弧的两个顶点在数组中的下标 */
	struct EBox *ilink, *jlink;		/* 分别指向这两个顶点的下一条边 */
	infoTYpe *info;				/* 弧本身的信息 */
} EBox;
typedef struct VexNode {			/* 顶点存储 */
	VertexType data;			/* 顶点信息 */
	EBox *firstedge;			/* 第一个边 */
} VexBox;
typedef struct {				/* 图的存储 */
	vexBox adjmulist[MAX_VERTEX_NUM];	/* 顶点数组 */
	int vexnum, arcnum;			/* 顶点数,弧数 */
} AMLGraph;


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值