Linked Lists - hard exercise(help needed)
i came across a really difficult exercise about linked lists..
and i cant seem to solve it
here's the question
there's a doubly linked list which is also circled (i.e the last node's next pointer points to the head of the list,and the head's prev pointer points to the last node).
the data in each node is an integer.
now a jump in a circular list is as follows:
if we have a node p :
if p.data is positive we move p.data times using the next pointer
if p.data is negative we move p.data times using the prev pointer
if p.data is 0 we dont move at all.
now you need to write a method that recieves as a paramater a pointer to the head of the list , and returns true if threre's a path that starts from the head node and ends there.
for this list the method will return true,because we start with 2 ,move to -5,
then move to 1(moving backwords) ,then -4 ,and then 2.
this is not homework(i'm working on different exercises in order to prepare my self to an exam)
help will be appreciated..
thank you very much.
Last Post: 06-18-2005, 06:56 AM
By white94cam in forum C++
Last Post: 03-31-2005, 12:02 AM
By Madhavi in forum Database
Last Post: 06-28-2002, 12:53 PM
Last Post: 12-01-2000, 05:26 AM
Last Post: 10-22-2000, 05:29 PM
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL