Otherwise you can take two pointers............ One at the beginning other at the end.... Increment the one pointing at the beginning ...and decrement one pointing to the end...... When both of their self referential pointer point to the same node...its the middle element......the one you wanted....
Now the question arise whether you know are allowed to have the last node or not.... Do care to reply.... Debasish Mickey Mathieson <[EMAIL PROTECTED]> wrote: --- sunil_h_v <[EMAIL PROTECTED]> wrote: > 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 ? > 1). Calculate the middle node by using simple arithmetic. 2). Traverse the list until reaching the calculated middle node. 3). Return the node information. Mickey M. Construction Partner Inc. http://www.constructionpartner.com __________________________________________________________ Pinpoint customers who are looking for what you sell. http://searchmarketing.yahoo.com/ 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]
