1. We have moved from vBulletin to XenForo and you are viewing the site in the middle of the move. Though the functional aspect of everything is working fine, we are still working on other changes including the new design on Xenforo.
    Dismiss Notice

finding middle node in liked list

Discussion in 'C' started by dhanulakshmi, Nov 29, 2006.

  1. dhanulakshmi

    dhanulakshmi New Member

    how to find the middle node of the linked list having some 10 nodes....i dont want to count the nodes n find the middle one....i have to travel the entire list for only one time....after coming to the end of the node ,i have to recpgnise n print the middle node

    thanks n regards
     
  2. shabbir

    shabbir Administrator Staff Member

    The best possible way out is do have a pointer to the middle node at the time of inserting as you can never know which one is the middle node unless you travel the whole list.

    You can also try one more thing is while travelling to find the middle node store the middle node to the particular node and when you will reach the end of the list you have the middle node stored.
     

Share This Page