Hello guys,
In an attempt to understand the Algorithm that reverses the Linked List, I wanted to see if I could explain this to someone else. Keep in mind, that I was trying to understand the algorithm myself, let me know in the comments below if this confused you as much as I tried to make sense of it.
I found reversing a Linked List confusing when it is quite manageable to understand, the idea is that you:
1. Create 3 Node Variables: next, prev, and current
2. Use next and prev to keep track of the nodes you before you change them
3. Flip the pointer of current.next to point to prev [This is important]
4. Move current into the prev variable (in order to free up current to be assigned to the next)
5. Make next as current (This makes sense because we moved current into prev, now we're making next as current)
6. Relink the prev to have it's previous node pointing to the next
Algorithms Study Notes,Data structure,Trees,LinkedList,
Thank you for explaining, this was confusing to me as well.