SqList
typedef struct
{
Elemtype *elem; Storage space Base
int length; Current length
int listsize; Current capacity
}sqlist;
L->elem = (elemtype*) mallloc (list_init_size*sizeof (elemtype)); l->length = 0; L->listsize = list_init_size;
L->elem = (elemtype*) realloc (L->elem, (l.listsize+listincrement) *sizeof (elemtype));
if (NULL = = L->elem) exit (OVERFLOW);
Destroy Operation Free (l->elem); l->elem = NULL; l->length = l->listsize = 0;
Sequential tables, sequential storage, initialization operations assign a predefined size array space to the order table, and redistribution (realloc) due to insufficient space to insert the element;
Linklistt
typedef struct LNODE
{
Elemtype data;
struct Lnode *next;
}lnode,*linklist;
L = (linklist) malloc (sizeof (Lnode)); L->next = NULL;
Destroy Destroy P = L; L = L->next;free (p); Clear clear only to retain the head node;
Linked list, create nodes and release nodes, nodes with data and pointers two information;
Comprehensive: Consider whether insert, delete operation is reasonable, otherwise exit (ERROR); Consider whether the storage allocation is successful (sqlist), otherwise exit (OVERFLOW);
Basic operation of sequential table and linked list