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:8,813
Registered: 10/4/00
Re: Reversing LinkedList elements  
Aug 8, 2004 2:43 PM (reply 105 of 142)



 
True, but I think the point that the beautiful, sexy,
delectable bbritta

http://www.noplacelikeoz.com/OZ-shucks.wav

was making (by the way, bbritta,
thanks for those pictures you sent me of
yourself--yum!)

[url http://favewavs.com/wavs/cartoons/woohoo.wav]Same here[/url]!!!

is that, even aside from the
unattainability of pure objectivity, many people don't
even try--they just assume that what they
want/think/feel must be "right" and must be the same
for everybody. I doubt it's limited to just us Yanks
though.

I couldn't have said it better myself.
 

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



 
You mean these two statements shouldn't be together?
 

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



 
can I have a look at them too bbritta ::grin::
 

Posts:37,103
Registered: 3/30/99
Re: Reversing LinkedList elements  
Aug 8, 2004 2:49 PM (reply 108 of 142)



 
You mean these two statements shouldn't be together?

No. That's not what I mean. I haven't even looked at the code.

You're complaining because you don't understand why those two statements have a loop between them. Or something like that.

Simple logic, completely without regard to Java or programming, gives us two possibilities:

1) The code as written is correct, and you just don't understand how it works. Stepping through it for a small list will remedy this, or at least lead to a new question that's closer to the heart of what's going on, if you invest the necessary time and effort.

2) The code as written is incorrect. If this code was provided by your instructor or textbook, then this is less likely than #1, but not impossible. Again stepping through slowly and seeing what the list looks like at the beginning, each intermediate step, and the end, will tell you if this is the case.

Either way, you have the tools at your disposal to come up with an answer, or at least a more thoughtful question than "why is there a loop between these statements?"
 

Posts:37,103
Registered: 3/30/99
Re: Reversing LinkedList elements  
Aug 8, 2004 2:50 PM (reply 109 of 142)



 
You mean these two statements shouldn't be together?

No. That's not what I mean. I haven't even looked at
the code.

And even if I had, I wouldn't just give you the answer as to whether they should be together and why or why not.
 

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



 
yeah, please ans. this
why is there a loop between these statements?
 

Posts:3,081
Registered: 2/15/99
Re: Reversing LinkedList elements  
Aug 8, 2004 2:58 PM (reply 111 of 142)



 
yeah, please ans. this
why is there a loop between these statements?

Somebody put it there.

If you don't like the loop, remove it.
 

Posts:357
Registered: 8/5/04
Re: Reversing LinkedList elements  
Aug 8, 2004 3:01 PM (reply 112 of 142)



 
Somebody put it there.

If you don't like the loop, remove it.

Good Point.
 

Posts:8,813
Registered: 10/4/00
Re: Reversing LinkedList elements  
Aug 8, 2004 3:05 PM (reply 113 of 142)



 
I award you no points, and may God have mercy on your soul.. - Max Anderson
 

Posts:357
Registered: 8/5/04
Re: Reversing LinkedList elements  
Aug 8, 2004 3:11 PM (reply 114 of 142)



 
" I am trying to imagine desperately, how a delightful lady like you looks like." - XTM
 

Posts:37,103
Registered: 3/30/99
Re: Reversing LinkedList elements  
Aug 8, 2004 3:11 PM (reply 115 of 142)



 
yeah, please ans. this
why is there a loop between these statements?

You're not talking to me are you? I already told you:

1) I can't answer it because I haven't read the code

2) Even if I'd read the code, I wouldn't answer it.
 

Posts:357
Registered: 8/5/04
Re: Reversing LinkedList elements  
Aug 8, 2004 3:16 PM (reply 116 of 142)



 
public void reverse()   {       if (first == null) return;      Link previous = first;      IO.println("Previous "+ previous + " " + "first " + first);      Link current = first.next;      first.next = null;// Why this thing  here <<<<<<      while (current != null)      {          Link next = current.next;         current.next = previous;         IO.println("current.next "+ current.next);          IO.println("previous "+ previous);         previous = current;         current = next;         IO.println("next "+ next);      }     //And NOT over HERE like this: first.next = null; ???       first = previous;   }
 

Posts:37,103
Registered: 3/30/99
Re: Reversing LinkedList elements  
Aug 8, 2004 3:40 PM (reply 117 of 142)



 
first.next = null;// Why this thing  here <<<<<<...//And NOT over HERE like this: first.next = null; ???first = previous;}

I'm curious--why are you so opposed to actually stepping through the code to understand how it works? There's not that much of it, and there shouldn't be much, if anything, that you haven't seen before. Do you have some religious objection to actually thinking for yourself?
 

Posts:357
Registered: 8/5/04
Re: Reversing LinkedList elements  
Aug 8, 2004 3:46 PM (reply 118 of 142)



 

I'm curious--why are you so opposed to actually
stepping through the code to understand how it works?
There's not that much of it, and there shouldn't be
much, if anything, that you haven't seen before. Do
you have some religious objection to actually thinking
for yourself?

time is the only objection nice man

had it been plenty in my hand & other resources i wouldn't be popping into forum
 

Posts:8,813
Registered: 10/4/00
Re: Reversing LinkedList elements  
Aug 8, 2004 3:52 PM (reply 119 of 142)



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