数据结构读书笔记3

一切为了:
Merge
1.《大话数据结构》

1.循环链表 circular linked list
合并:

p = rearA->next;
rearA->next = rearB->next->next;
rearB->next = p;
free(p);

2.双向链表 double linked list

typedef struct DulNode
{
    ElemType data;
    struct DulNode *prior;
    struct DulNode *next;
} DulNode, *DuLinkList;

插入操作:
思想:
先解决插入结点的前驱和后继,后结点的前驱,前结点的后继。

s->prior = p;
s->next = p->next;
p->next->prior = s;
p->next = s;

删除操作:

p->prior->next = p->next;
p->next->prior = p->prior;
free(p);

你可能感兴趣的:(数据结构/算法)