首页 > 其他 > 详细

数据结构实现过程

时间:2014-03-26 04:09:28      阅读:448      评论:0      收藏:0      [点我收藏+]

数据结构实现过程

1. 定义数据元素

2. 定义数据结点

3. 定义数据结构

4. 定义数据操作 

顺序表

顺序表

数据元素

typedef  xxx ElemType;

数据结点

采用数组作为顺序存储结构,无需额外定义

数据结构

法一:

typedef struct

{

    ElemType *elem;

    int length;

    int size;

}List;

法二:

#define MAXSIZE 100

typedef  struct List

{  

    ElemType  *elem;

    int    length;

}List;

数据操作

//初始化

Status ListInit(List &L);

//销毁顺序表

Status ListDestroy(List &L);

//在顺序表L的pos位置插入e

Status ListInsert(List &L, int pos, ElemType e);

//遍历顺序表

Status ListVisit(List &L);

//在顺序表L中查找e

Status LocateElem(const List L, ElemType e);

//在顺序表L中删除pos位置的元素,并用e返回其值

Status ListDelete(List &L, int pos, ElemType &e);

 

Status ListGetElem(List L,int i, ElemType &e);

……

 

链表

链表

数据元素

typedef  xxx ElemType;

数据结点

typedef struct LNnode

{

    ElemType data;

    struct LNode *next;

}*Link

数据结构

typedef struct

{

    Link head,tail;

    int length;

}List;

数据操作

Status ListInit (LinkList &L);

Status ListDestroy(LinkList &L);

Status ListInsert(LinkList &L, int pos, ElemType e);

Status ListLocate(LinkList L,int i,Link &p);

Status GetElem(Link &p, ElemType &e);

……

 

 

 

 

数据元素

typedef  xxx ElemType;

数据结点

typedef  struct  StackNode

{

    ElemType  data;

    struct stacknode *next;

}StackNode,*LinkStack;

数据结构

LinkStack pss;

数据操作

Status StackInit(LinkStack &LS);

Status StackDestroy(LinkStack &LS);

Status Push(LinkStack &LS,ElemType e);

Status Pop(LinkStack LS, ElemType &e);

Status StackEmpty(LinkStack LS);

……

 

 

队列

队列

数据元素

typedef  xxx ElemType;

数据结点

typedef struct Qnode

    ElemType data ;

    struct Qnode *next ;

}QNode ;

数据结构

typedef struct link_queue

    QNode  *front ;

    Qnode  *rear ;

}Link_Queue ;

数据操作

Status QueueInit (LinkQueue &Q);

Status QueueDestroy(LinkQueue &Q);

Status QueueInsert(LinkQueue &Q , ElemType e);

Status QueueDelete(LinkQueue &Q, ElemType &e);

……

 

二叉排序树

二叉排序树

数据元素

typedef xxx KeyType;

typedef yyy ElemType;

数据结点

typedef struct Node

    KeyType key;

    ElemType  data ;

    struct Node  *Lchild,*RChild ;

}BSTNode ;

数据结构

BSTNode  T;

数据操作

Status BSTInsert (BSTNode &T, KeyType  key);

Status BSTDelete(BSTNode &T, KeyType  key);

Status BSTSearch(BSTNode &T, KeyType  key, BSTNode &e);

……

数据结构实现过程,布布扣,bubuko.com

数据结构实现过程

原文:http://www.cnblogs.com/whl2012/p/3624378.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!