参考图中删除节点的链表,写出单链表插入和删除一个节点的伪代码算法。 节点包含数据data和链接next
参考资料:
插入:
set linkedlist to [a1,a2,a3...ai-1,ai+1...an]
ai-1 node = p
ai+1 node = q
ai node = t
p->next = q
t->next = p->next
p->next = t
删除:
set linkedlist to [a1,a2,a3...ai-1,ai,ai+1...an]
ai-1 node = p
ai+1 node = q
ai node = t
p->next = t->next
free(t)