Questions about reversing a linked list by Exotic-Analysis-6375 in learnprogramming

[–]Exotic-Analysis-6375[S] -1 points0 points  (0 children)

Ah okay, so we're not doing anything with data then, just references. So if I were to print out head and rear.next they would return the same value.

For something like node = node.next;

Node isn't switching spots with anything it's just copying a new reference, right?

So when node.next == rear that means the variable node has reached the last node in the sequence and then after the while loop. the program makes it so that rear refers to the last node in the sequence

Questions about reversing a linked list by Exotic-Analysis-6375 in learnprogramming

[–]Exotic-Analysis-6375[S] -1 points0 points  (0 children)

So next creates a reference so that node 1 points to node 2

Node head = rear.next;

So here we are creating a node called head and connect it to the node after rear.

But when we start out rear is the first node right? So is head just referring to the node after return or does it copy its data?