0

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 Answer 1

0

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.