美文网首页
Chapter.1 Linear List

Chapter.1 Linear List

作者: Yovey | 来源:发表于2017-12-02 01:52 被阅读0次

    Abstract Data Type LinearList

      ADT LinearList{
        Data Element:D={a[i]|a[i]∈Dt,i=1,2,...,n,n>=0,Dt is some Data Type}
        Struct Relation:R={<a[i],a[i+1]>|a[1],a[i+1]∈Dt,i=1,2,...,n-1}
        Basic Operation:
        1.InitList(L)
        Operation Premise:L is an uninitialized Linear List.
        Operation Result:Initialize L as an empty table.
        2.Listlength(L)
        Operation Premise:L is existence.
        Operation Result:If L is empty,return 0,or return the count of element in L.
        3.LocateElem(L,e)
        Operation Premise:L is existence ande is a legal element value.
        Operation Result:If L have e,return the location of e,or return 0.
        4.GetElem(L,i)
        Operation Premise:L is existence,and 1<=i<=ListLength(L).
        Operation Result:Return the value of ith element in L.
        5.ListInsert(L,i,e)
        Operation Premise:L is existence,e is a legal element value and 1<=i<=ListLength(L)+1.
        Operation Result:Insert a new element  before location i in L,length of L add 1.
        6.ListDelete(L,i,e)
        Operation Premise:L is existence and not null,1<=i<=ListLength(L).
        Operation Result:Delete ith element in L,and return its value with e,length of L minus 1.
        7.PrintList(L)
        Operation Premise:L is existence and not null.
        Operation Result:Print all element in L.
        9.EmptyList(L)
        Operation Premise:L is existence.
        Operation Result:Return 1 when L is empty,else return 0.
        10.DestroyList(L)
        Operation Premise:L is existence.
        Operation Result:Free the memory of L.
        11.ClearList(L)
        Operation Premise:L is existence.
        Operation Result:Put L as an empty table.
      }
    

    Sequence List(Static allocation&Dynamic allocation)

    • Static allocation

      #define MaxSize 50
      typedef struct
      {
        int data[MaxSize];
        int length;
      }SqList;
      

    • Dynamic allocation

      #define InitSize 100
      typedef struct
      {
        int *data;
        int MaxSize,length;
      }SeqList;
      

    to be continue...

    相关文章

      网友评论

          本文标题:Chapter.1 Linear List

          本文链接:https://www.haomeiwen.com/subject/rxdgbxtx.html