ok i gt this mail a little late after replying d first one.sorry for that
in this mail u mentioned that u dont know n,
so u can use two pointers ,one for insertion n second to keep track of last
node index
from that i think u can calculate middle node
Mickey Mathieson <[EMAIL PROTECTED]> wrote:
--- 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.
Its inportant you give ALL info when asking for help.
Then use two pointer as seguested by OP but wathc out
for case of 1 item in the list.
Mickey M.
Construction Partner Inc.
http://www.constructionpartner.com
__________________________________________________________
Catch up on fall's hot new shows on Yahoo! TV. Watch previews, get listings,
and more!
http://tv.yahoo.com/collections/3658
---------------------------------
Moody friends. Drama queens. Your life? Nope! - their life, your story.
Play Sims Stories at Yahoo! Games.
[Non-text portions of this message have been removed]