21.数据结构-线性表-4.双向链表

3-14-5.jpg

1.双向链表的增加

“/* 把p赋值给s的前驱,如图中① */
s->prior = p;          
/* 把p->next赋值给s的后继,如图中② */
s->next = p->next;     
/* 把s赋值给p->next的前驱,如图中③ */
p->next->prior = s;    
/* 把s赋值给p的后继,如图中④ */”
p->next = s;

2.双向链表的删除


3-14-6.jpg
“/* 把p->next赋值给p->prior的后继,如图中① */
p->prior->next = p->next;     
/* 把p->prior赋值给p->next的前驱,如图中② */
p->next->prior = p->prior;    
/* 释放结点 */
free(p); ”

你可能感兴趣的:(21.数据结构-线性表-4.双向链表)