kayl
October 25th, 2004, 01:40 PM
In reversing a doubly linked list ... i think the idea is to
1- swap head and tail
2- swap the next and previous for each node .
but the problem is how can u reach each individual node to swap its references.
// swap tail and head
Node temp = tail;
tail = head;
head = temp;
Node first = temp.getNext();
while( first != null ) {
// swap next and previous for first
first = first.getNext() // the problem is here on this line .. that is that first now
is the ( tail ) so i cant go to the next node to swap its references ....
Please anyone can help ....
1- swap head and tail
2- swap the next and previous for each node .
but the problem is how can u reach each individual node to swap its references.
// swap tail and head
Node temp = tail;
tail = head;
head = temp;
Node first = temp.getNext();
while( first != null ) {
// swap next and previous for first
first = first.getNext() // the problem is here on this line .. that is that first now
is the ( tail ) so i cant go to the next node to swap its references ....
Please anyone can help ....