zoukankan      html  css  js  c++  java
  • 数据结构实现过程

    数据结构实现过程

    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);

    ……

  • 相关阅读:
    lumen 错误&日志
    Composer设置忽略版本匹配的方法
    Laravel框架数据库CURD操作、连贯操作使用方法
    laravel5-目录结构分析
    Lumen 设置 timezone 时区
    phpstorm laravel单元测试 配置
    使用laravel的Eloquent模型获取数据库的指定列
    phpstorm 配置自带webserver ,配置根目录
    使用 OWIN 作为 ASP.NET Web API 的宿主
    angularjs webstorm 单元测试 Package.json
  • 原文地址:https://www.cnblogs.com/whl2012/p/3624378.html
Copyright © 2011-2022 走看看