Insertion and deletion operations of data structure doubly linked list

Regardless of the operation of the doubly linked list, you must pay great attention to the sequence problem, because each node has an additional precursor pointer, so a big error will occur if the sequence is wrong.
1. The insertion operation of the doubly linked list.
insert image description here
Code example:

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

2.
insert image description here
Code example of delete operation of doubly linked list;

p->prior->next=p->next;
p->next->prior=p->prior;
delete(p);              //c语言使用free

Guess you like

Origin blog.csdn.net/qq_51344334/article/details/119784790