0
Cat------>Dog------>Horse----->Parrot  
^P1       ^P2       ^P3        ^P4  

Draw the resulting linked list after executing the following statements:

P4 = P2;  
P3.info = P2.info  

etc.

My question is, what does '.info' reference?
I've looked in the API for both node and linked list and haven't found anything.
Any ideas?

4
  • 2
    Is the homework asking you to associate all the information on the properties of the object from P3 to P2? I am not enrolled in your class so I have no idea what .info implies. Commented Nov 22, 2010 at 2:10
  • 1
    Please use a descriptive title the next time, "help!!" is not the best term to be used in a title. Also use the homework tag :) Commented Nov 22, 2010 at 2:13
  • thanks for the edit Ivo. i'll be sure to use your advice next time. Commented Nov 22, 2010 at 2:32
  • Anthony, that is literately the entire question... (minus a few more similar statements). Commented Nov 22, 2010 at 2:33

2 Answers 2

1

This would entirely depend on the specific implementation used in your assignment, but it sounds like info contains the data of the specific node in the linked list, i.e. P1.info is Cat.

Sign up to request clarification or add additional context in comments.

1 Comment

Depends if P2 is pointing to cat or dog. p1=p2 changes p1 so that it references the same object as p2. If p1 had previously referenced a different object then this original object would no longer have a reference to it but would still exist in memory (in java orphaned objects are automatically flagged for garbage collection). p1.info = p2.info sets the data portion of p1 to be the same as p2, overwriting whatever was originally in p1.info.
0

Each node in a standard linked list has two pieces of information:

  1. A reference the the next node
  2. The data contained in the current node

I'm not sure if your instructor wants you to take into account that you would have to "clone" the node in order to have a separate object with the same data or if your instructor wants you to take it literally where setting one object equal to another object simply makes the first one a reference to the second one.

As spookyjon said, the info appears to be a public variable in the node class for the data (cat, dog, horse, parrot).

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.