Take int half = n/2
while counter != half
keep traversing
make one more traverse
and there you reach your destiny...
isn't that easy ?
sunil_h_v <[EMAIL PROTECTED]> wrote:
I have reposted this question with a new topic, some how it had become
a part of some other topic, my apologies for the error committed by me.
Hi everyone,
I have a problem, i need the logic for it, i dont want any code
snippets or program for it. If you know please explain the logic for this.
Given a linked list of n nodes, n is an odd number, i.e; there are odd
number of nodes in it, I need to find the middle node of the linked
list, i am supposed to traverse only once, i am not supposed to use
any kind of an array to store the address values of the nodes, i am
allowed to use pointers.
How do i go about solving this problem ?
No codes or program please.
Regards,
Sunil.
Mr. Mickey replied to my earlier post and told me to use simple
arithematic to find the middle node and traverse till that node and
return the info in that node, but sir, the number of nodes is not
known, it is only n, value of n is not known, it is known as an odd
number, value of n is odd only, thats the only thing specified, if i
had known the value of n, i would have very easily traversed till n/2
node and returned the value at that location, but that cannot be done
because i have no idea of the number of nodes in the list.
It is just a linked list, with one traversal can it be done ? how so ?
Regards
Sunil.
Karmennevaya Dhikaraste, Maaphaaleshu Kadaachanah
---------------------------------
Now you can chat without downloading messenger. Click here to know how.
[Non-text portions of this message have been removed]