definition
Also known as doubly linked list doubly linked list is a linked list, which in each data node has two pointers point to direct predecessor and successor directly. So, start from any one node in a doubly linked list, you can easily access its predecessor nodes and successor node. Generally, we have constructed two-way circular list (the list can only solve the problem of a single node in order to access the order from scratch backward traversal)
type of representation doubly linked list of nodes as follows:
typedef struct DNode{ //定义双链表结点类型
EleType data; //数据域
struct DNode *prior,*next; //前驱和后继指针
}DNode,*DLlinklist;
Doubly linked list of logical structure:
Basic operation of the doubly linked list
1, the insert
in the doubly linked list node before insertion p referred nodes * s, which changes the pointer follows:
insert the following code fragment:
s->next = p->next; //将结点*s插入到结点*p之后
p->next->prior = s;
s->prior = p;
p->next = s;
[Note] the above code sequence of statements is not unique, but not arbitrary; must be before the fourth sentence as in the first, the two.
2, the delete operation
to delete the doubly linked list node * p, the process changes its pointer follows:
deletion of the following code fragment:
p->next = q;
q->next =->prior = p;
free(q); //释放结点空间
[Note] A is a p junction point, b is the node q