Go4Expert

Go4Expert (http://www.go4expert.com/)
-   C (http://www.go4expert.com/forums/c/)
-   -   finding middle node in liked list (http://www.go4expert.com/forums/finding-middle-node-liked-list-t2054/)

dhanulakshmi 29Nov2006 11:18

finding middle node in liked list
 
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

shabbir 29Nov2006 12:18

Re: finding middle node in liked list
 
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.


All times are GMT +5.5. The time now is 23:54.