中间的未知长度的单链表 [英] Middle of a singly linked list of unknown length

查看:73
本文介绍了中间的未知长度的单链表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨!


我想知道,在未知

长度的单链表的第一个解析中,是否有可能知道我们什么时候在链表的中间?


问候

- 希曼舒

解决方案

< blockquote>文章< g2 ********** @ aioe.org>,

Himanshu Chauhan< ch ********* @ gmail.comwrote:


>我想知道,在未知
长度的单链表的第一个解析中,是否有可能知道我们何时处于中间位置链表?



显然不是,因为如果额外的元素是

添加到最后,没有什么会有所不同。


- Richard

-

在紧接着数字9的两个字符的选择中,

应给予考虑将图形10和11替换为

便于在英镑货币区域采用该代码。 (X3.4-1963)



我想知道,在未知的单链表的第一个解析

长度,是否可以知道我们何时处于链表的中间?



你可以这样做,如果你在建造它的时候跟踪列表中有多少人。


6月6日下午1:48,Himanshu Chauhan< chauhan .... @ gmail.comwrote:


嗨!


我想知道,在单个链接的未知

长度列表的第一个解析中,是否有可能知道我们何时处于链接的中间位置清单?


问候

--Himanshu



您可以保留插入的节点数作为静态或全局

变量。通过计算

的迭代次数,你可以决定你是否在列表的中间位置。


刚出来好奇心,这个问题是针对一些真实的代码或者是

就像那样。


Hi!

I was wondering, In the first parse of a singly linked list of unknown
length, is it possible to know when we are at middle of the linked list?

Regards
--Himanshu

解决方案

In article <g2**********@aioe.org>,
Himanshu Chauhan <ch*********@gmail.comwrote:

>I was wondering, In the first parse of a singly linked list of unknown
length, is it possible to know when we are at middle of the linked list?

Obviously not, since nothing would be different if extra elements were
added to the end.

-- Richard
--
In the selection of the two characters immediately succeeding the numeral 9,
consideration shall be given to their replacement by the graphics 10 and 11 to
facilitate the adoption of the code in the sterling monetary area. (X3.4-1963)


I was wondering, In the first parse of a singly linked list of unknown
length, is it possible to know when we are at middle of the linked list?

You could do it if you kept track of how many were in the list when you
built it.


On Jun 6, 1:48 pm, Himanshu Chauhan <chauhan....@gmail.comwrote:

Hi!

I was wondering, In the first parse of a singly linked list of unknown
length, is it possible to know when we are at middle of the linked list?

Regards
--Himanshu

You can keep the count of nodes inserted as a static or global
variable. By counting
the number of iterations, you can decide if you are in the middle of
the list.

Just out of curiosity, this question is meant for some real code or is
it just like that.


这篇关于中间的未知长度的单链表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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