数据结构-存储结构
程序员文章站
2022-03-24 17:27:32
...
数据结构-存储结构
1. 图的存储结构:
a) 邻接矩阵:
#define MaxVertexNum 100
typedef char VertexType;
typedef int EdgeType;
typedef struct MGragh{
VertexType Vex[MaxVertexNum];
EdgeType Edge[MaxVertexNum][MaxVertexNum];
int vexnum,arcnum;
}MGragh;
a) 邻接表法:
#define MaxVertexNum 100
typedef struct ArcNode{ //边表节点
int adjvex;
struct ArcNode *next;
}ArcNode;
typedef struct VNode{ //顶点表节点
VertexType data;
ArcNode *first;
}VNode,AdjList[MaxVertexNum];
typedef struct AMLGraph{ //邻接表
AdjList vertices;
int vexnum,arcnum;
}AMLGraph;
2.二叉树链式存储结构:
typdef int ElemType;
typedef struct BiTNode{
ElemType data;
struct BitNode *lchild,*rchild;
}BiTNode,*BiTree;
3.顺序栈的存储结构:
#define MaxSize 50
typedef int Elemtype;
typedef struct{
Elemtype data[MaxSize];
int top;
}SqStack;
4.栈的链式存储:
typedef struct ThredNode{
ElemType data;
struct ThreadNode *lchild,*rchild;
int ltag,rtag; //0表示指孩子,1表指前驱或后继
}ThreadNode,*ThreadTree
typedef int ElemType;
typedef struct{
ElemType data;
struct LinkNode *next;
}LinkNode,*LiStack;
5.单链表的存储结构:
typedef int ElemType;
typedef struct LNode{
ElemType data;
struct LNode *next;
}LNode,*LinkList;
线索二叉树的存储结构
typedef struct ThredNode{
ElemType data;
struct ThreadNode *lchild,*rchild;
int ltag,rtag; //0表示指孩子,1表指前驱或后继
}ThreadNode,*ThreadTree
上一篇: JS切换图片幻灯切换效果