Home arrow static arrow Java Programming [Archive] - Reversing LinkedList elements
Warning: Creating default object from empty value in /www/htdocs/w008deb8/wiki/components/com_staticxt/staticxt.php on line 51
Java Programming [Archive] - Reversing LinkedList elements
This topic has 142 replies on 10 pages.    « Previous | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | Next »

Posts:357
Registered: 8/5/04
Re: Reversing LinkedList elements  
Aug 8, 2004 1:22 PM (reply 75 of 142)



 
oh so first is like an engine of the train right?

having x no. of elements attached to it?

Is this question stupid?
 

Posts:8,813
Registered: 10/4/00
Re: Reversing LinkedList elements  
Aug 8, 2004 1:22 PM (reply 76 of 142)



 
Let us learn to dream, gentlemen, and then we may perhaps find the truth - F.A. Keule
 

Posts:18,384
Registered: 21.03.00
Re: Reversing LinkedList elements  
Aug 8, 2004 1:25 PM (reply 77 of 142)



 
oh so first is like an engine of the train right?

having x no. of elements attached to it?

Hi, yes can look at it in that way.

/Kaj

 

Posts:357
Registered: 8/5/04
Re: Reversing LinkedList elements  
Aug 8, 2004 1:25 PM (reply 78 of 142)



 
Let us learn to dream, gentlemen, and then we may
perhaps find the truth
- F.A. Keule

Hello sweet lady bbritta (I hope).

are you a teacher too?

 

Posts:357
Registered: 8/5/04
Re: Reversing LinkedList elements  
Aug 8, 2004 1:29 PM (reply 79 of 142)



 
oh so first is like an engine of the train right?

having x no. of elements attached to it?

Hi, yes can look at it in that way.

/Kaj


first.next = null //does it mean continue till you reach END of the LinkedList?
 

Posts:8,813
Registered: 10/4/00
Re: Reversing LinkedList elements  
Aug 8, 2004 1:30 PM (reply 80 of 142)



 
I think so. I think Freidrich Kekule's insight into the structure of benzene is applicable here if you decide to investigate it.
 

Posts:357
Registered: 8/5/04
Re: Reversing LinkedList elements  
Aug 8, 2004 1:33 PM (reply 81 of 142)



 
I think so. I think Freidrich Kekule's insight into
the structure of benzene is applicable here if you
decide to investigate it.

what u mean this thing is resonating?
 

Posts:8,813
Registered: 10/4/00
Re: Reversing LinkedList elements  
Aug 8, 2004 1:35 PM (reply 82 of 142)



 
Wait for it.....
 

Posts:357
Registered: 8/5/04
Re: Reversing LinkedList elements  
Aug 8, 2004 1:37 PM (reply 83 of 142)



 
... i can't wait teacher bbritta
 

Posts:8,813
Registered: 10/4/00
Re: Reversing LinkedList elements  
Aug 8, 2004 1:47 PM (reply 84 of 142)



 
Imagine a train where the engine and caboose are the same car.
 

Posts:357
Registered: 8/5/04
Re: Reversing LinkedList elements  
Aug 8, 2004 1:51 PM (reply 85 of 142)



 
Imagine a train where the engine and caboose are the
same car.

done now what? whats the use of first.next = null ?
 

Posts:18,384
Registered: 21.03.00
Re: Reversing LinkedList elements  
Aug 8, 2004 1:57 PM (reply 86 of 142)



 
Think for a moment. Where will the first item be when you have reversed the list??

/Kaj
 

Posts:8,813
Registered: 10/4/00
Re: Reversing LinkedList elements  
Aug 8, 2004 2:01 PM (reply 87 of 142)



 
If you really got the picture, this should be easy. If you were just blowing me off it's going to be much harder.

1. Draw a picure of the train I described above.

2. Put the tip of your pencil on the engine/caboose.

3. Move your pencil to the next car behind

4. If there is another car behind go to step 3

5. Post your answer
 

Posts:18,384
Registered: 21.03.00
Re: Reversing LinkedList elements  
Aug 8, 2004 2:03 PM (reply 88 of 142)



 
Now bbritta. Does it matter if a paint a steam engine, or an electrical one? :p

/Kaj
 

Posts:357
Registered: 8/5/04
Re: Reversing LinkedList elements  
Aug 8, 2004 2:12 PM (reply 89 of 142)



 
Think for a moment. Where will the first item be when
you have reversed the list??

Lets see ... heres what i thought

Link previous = first ; all the links (elements) went into previous        Link current  = first.next; // all other links went into current except  FIRST (element which is 1)         first.next = null ; //NOW we DON"T need this thing anymore therefore null...  

Correct?

 
This topic has 142 replies on 10 pages.    « Previous | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | Next »