双向链表结构:
typedef structDualNode
{
ElemType data;
struct DualNode*prior; //前驱结点
struct DualNode*next; //后继结点
} DualNode, *DuLinkList;
既然单链表可以有循环链表,那么双向链表当然也可以有:
双向链表的插入操作:
- s->next = p;
- s->prior = p->prior;
- p->prior->next = s;
- p->prior = s;
双向链表的删除操作:
- p->prior->next = p->next;
- p->next->prior = p->prior;
- free(p);
网友评论