Re: Middle of a singly linked list of unknown length
- From: "Bartc" <bc@xxxxxxxxxx>
- Date: Fri, 06 Jun 2008 15:34:59 GMT
"Kenneth Brody" <kenbrody@xxxxxxxxxxx> wrote in message
news:484954EE.DE3F5A81@xxxxxxxxxxxxxx
Himanshu Chauhan wrote:
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?
The me rephrase the problem, and see if you can find a solution:
Drive down this road and stop halfway to a destination which I
have not yet revealed.
That's not quite the same. In that case you would not know when you got to
the destination so it's unsolveable. A linked list however has a definite
end point, assuming it's not circular.
Better, 'stop halfway to the end of the road of unknown length'. Easily done
by traversing the entire length one and a half times.
--
Bartc
.
- Follow-Ups:
- Re: Middle of a singly linked list of unknown length
- From: Kenneth Brody
- Re: Middle of a singly linked list of unknown length
- References:
- Middle of a singly linked list of unknown length
- From: Himanshu Chauhan
- Re: Middle of a singly linked list of unknown length
- From: Kenneth Brody
- Middle of a singly linked list of unknown length
- Prev by Date: Re: Bug/problem with lcc-win
- Next by Date: Re: What would be the right warning/error?
- Previous by thread: Re: Middle of a singly linked list of unknown length
- Next by thread: Re: Middle of a singly linked list of unknown length
- Index(es):
Relevant Pages
|