well, i guess, you need to create list first before getting the middle
element.
as and when you list, keep a counter variable that keeps track of total
number of nodes in list.
then, divide by 2 to get mid array node.....
then, traverse the list only once, until the variable/2 value becomes 0.
you will have access to the mid node of an array....
if your problem is solved... please let me know...
On 10/12/07, Vic Wagner <[EMAIL PROTECTED]> wrote:
>
> Mickey Mathieson wrote:
> > --- Vic Wagner <[EMAIL PROTECTED] <joel%40rudbekassociates.com>>
> wrote:
> >
> >
> >> Mickey Mathieson wrote:
> >>
> >>> --- Vic Wagner <[EMAIL PROTECTED]<joel%40rudbekassociates.com>>
> wrote:
> >>>
> >>>
> >>>
> >>>> Mickey Mathieson wrote:
> >>>>
> >>>>
> >>>>> --- sunil_h_v <[EMAIL PROTECTED] <sunil_h_v%40yahoo.co.in>>
> wrote:
> >>>>>
> >>>>>
> >>>>>
> >>>>>
> >>>>>> Hi everyone,
> >>>>>>
> >>>>>> I have a problem, i need the logic for it, i
> >>>>>>
> >>>>>>
> >>> don't
> >>>
> >>>
> >>>>>> 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.
> >>>>>
> >>>>>
> >>>>>
> >>>> If you don't know the length of the list
> >>>>
> >> beforehand,
> >>
> >>>> what "simple
> >>>> arithmetic" do you perform?
> >>>>
> >>>>
> >>> Where does it state that you don't know the length
> >>>
> >> of
> >>
> >>> the list?
> >>>
> >>>
> >>>
> >
> >
> >> it doesn't say you DO know, therefore you don't.
> >>
> >
> >
> > depends on how you look at things - half empty or half
> > full.
> >
> >
> empty/full has nothing to do with it.
>
> correct / incorrect
>
> correct trumps
>
> [Non-text portions of this message have been removed]
>
>
>
--
Thank You,
The Clouds That Wander Through The
Sky Have No Roots, No Home;
Nor The Distinctive Thoughts Floating Through The Mind...
[Non-text portions of this message have been removed]