如果您只知道最后一个节点的地址,如何删除链接列表的最后一个节点。 [英] how to delete last node of a Linked list if you only know the address of last node.

查看:70
本文介绍了如果您只知道最后一个节点的地址,如何删除链接列表的最后一个节点。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果您只知道最后一个节点的地址

,如何删除链接列表的最后一个节点。


感谢

sangram

how to delete last node of a Linked list if you only know the address
of last node.

thanks
sangram

推荐答案

hi

开始遍历节点

看看是否它指向的节点与你拥有的地址具有相同的地址

如果它不是那么转到下一个节点并继续这个过程

如果你找到地址:

1将prev节点'(你现在在哪里)下一个参数设为null

然后转到下一个节点并复制一份..

之后执行步骤1并释放复制的节点。

sangram写道:
hi
start traversing the node
see if the nodes it points to has the same address as the one you have
if it isnt then goto the next node and continue this process
if u find the address:
1set the prev node''s( where u are right now) next parameter to null
before go to the next node and make a copy..
after that do step no 1 and free the copied node.
sangram wrote:

如何删除链接列表的最后一个节点如果你只知道最后一个节点的地址




谢谢

sangram
how to delete last node of a Linked list if you only know the address
of last node.

thanks
sangram


嗨朋友,


如果你知道节点的开始就可以了。


但只有你硝酸钾w结束节点,现在你删除它。


感谢您的通信。
ra ******************* @ gmail.com 写道:
hi friend,

its ok if u know the start of the node.

but only you know the end node and now u delete it.

thanks for comunication.
ra*******************@gmail.com wrote:

hi

开始遍历节点

查看它指向的节点是否与您拥有的节点具有相同的地址

如果不是那么转到下一个节点并继续这个过程

如果你找到地址:

1设置prev节点''(你在哪里)现在)下一个参数为null

然后转到下一个节点并复制..

之后执行步骤1并释放复制的节点。

sangram写道:
hi
start traversing the node
see if the nodes it points to has the same address as the one you have
if it isnt then goto the next node and continue this process
if u find the address:
1set the prev node''s( where u are right now) next parameter to null
before go to the next node and make a copy..
after that do step no 1 and free the copied node.
sangram wrote:

如果你只知道最后一个节点的地址

,如何删除链接列表的最后一个节点。


谢谢

sangram
how to delete last node of a Linked list if you only know the address
of last node.

thanks
sangram




sangram写道:

sangram wrote:

如果您只知道最后一个节点的地址

,如何删除链接列表的最后一个节点。
how to delete last node of a Linked list if you only know the address
of last node.



你不能,因为你需要知道前一个

节点的地址才能设置它的"下一步]指向null的指针。如果你想要能够删除任意节点而不需要知道任何其他节点的地址,那么你需要实现一个

双向链表。也就是说,每个节点将具有下一个节点。和

之前指针。


MQ

You can''t, because you would need to know the address of the previous
node in order to be able to set its "next" pointer to null. If you
want to be able to remove any arbitrary node without needing to know
the address of any other node, then you will need to implement a
doubly-linked list. That is, each node will have a "next" and
"previous" pointer.

MQ


这篇关于如果您只知道最后一个节点的地址,如何删除链接列表的最后一个节点。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆