That's one solution....but I am having memory constraint....so need some
optimized algo

On 4/4/07, Dhruva Sagar <[EMAIL PROTECTED]> wrote:
>
> Yes and hence i mentioned that it would be better if you have a unique key
> such as an index as a property of the node itself. For example the info part
> of the node may have a index.
>
> Then you could add that unique key to an array and check and compare that
> to determine if a node is being traversed again.
>
> On 4/4/07, Pradeep Juneja <[EMAIL PROTECTED]> wrote:
> >
> > It will consume lot of memory (varying on the length of link list).....
> >
> > On 4/4/07, Dhruva Sagar < [EMAIL PROTECTED] > wrote:
> > >
> > > I guess you can keep an array of node pointers where you could add the
> > > addresses of the nodes as you traverse through the link list. And you 
> > > could
> > > loop through the array to match the current node to the traversed nodes. 
> > > If
> > > there is a match it means that you are encountering that node again and
> > > hence the link list is looping at that node.
> > >
> > > It would be nice if you simply had a unique key as a property of the
> > > node itself though, such as an index or something...
> > >
> > > On 4/4/07, Pradeep Juneja <[EMAIL PROTECTED]> wrote:
> > > >
> > > > Which data structure will be used to keep track of unique
> > > > identifier?
> > > >
> > > > We are not allowed to modify the struct node of linked list
> > > >
> > > > On 4/4/07, Dhruva Sagar <[EMAIL PROTECTED]> wrote:
> > > > >
> > > > >  It would be easy to do in case there is a unique identifier for
> > > > > each node.
> > > > > Simply traverse through the link list and when you encounter a
> > > > > node twice it means that the link list is looping at that node.
> > > > >
> > > > > On 4/4/07, Pradeep Juneja <[EMAIL PROTECTED]> wrote:
> > > > > >
> > > > > >
> > > > > >
> > > > > > How can we know at what node, list has the loop ?
> > > > > > i.e
> > > > > > A---->B----->*C*------->D------>E------F-----
> > > > > >                         |
> > > > > >         |
> > > > > >                         ----------------------------- - -|
> > > > > >
> > > > > >
> > > > > >
> > > > >
> > > > >
> > > > > --
> > > > > Thanks & Regards,
> > > > > Dhruva Sagar.
> > > > >
> > > > >
> > > > >
> > > >
> > > >
> > > >
> > > >
> > >
> > >
> > > --
> > > Thanks & Regards,
> > > Dhruva Sagar.
> > >
> > >
> > >
> >
> >
> >
> >
>
>
> --
> Thanks & Regards,
> Dhruva Sagar.
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/algogeeks
-~----------~----~----~----~------~----~------~--~---

Reply via email to