删除节点单链表 [英] Delete a node in singly link list
问题描述
如何删除一个节点的单独只用一个指针指向节点被删除的链接列表?
How to delete a node in a singly link list with only one pointer pointing to node to be deleted?
[开始和结束指针是不知道,现有的资料是指向节点应该将其删除]
[Start and end pointers are not known, the available information is pointer to node which should be deleted]
推荐答案
不可能的。
有黑客模仿删除。
但是,没有,那么实际上将删除该指针所指向的节点。
删除以下节点,并复制其内容的实际节点要删除的流行的解决方案有副作用,如果你有外部指针强>指向列表中的节点,在这种情况下,指向后面的节点的外部指针将成为悬挂
The popular solution of deleting the following node and copying its contents to the actual node to be deleted has side-effects if you have external pointers pointing to nodes in the list, in which case an external pointer pointing to the following node will become dangling.
您可以找到SO <一一些讨论href=\"http://stackoverflow.com/questions/69209/deleting-a-middle-node-from-a-single-linked-list-when-pointer-to-the-$p$pvious-nod\">here.
这篇关于删除节点单链表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!