Conceptualizing a linked-list post reversal

29 Views Asked by At

I'm seeking clarification on how to properly understand a singly linked list once it has been reversed. Typically, the first element of the list should always be stored at the head of the linked list. However, upon reversing, does this imply that the head of the list is now shifted to what was originally the last node?

If we intend to add a new element at the start, should we treat the former tail, now transformed into the head, as the new starting point of the list? Thanks

1

There are 1 best solutions below

0
Gassa On

Yes, the old tail is now the head.

One way to think about it is as follows. The list has no memory of its history. So, it does not remember what was its head. Only what is its head now.

Now, if the head is anything but the old tail, some of the elements (for example, the old tail) would be inaccessible from the new head. We shouldn't lose elements by doing a reverse (doing another reverse should restore the old list, so, everything should still be accessible). So, the new head has to be the old tail.