1. **Problem Statement:** Reverse a singly linked list, which means to change the direction of the pointers so that the last node becomes the first and the first becomes the last.
2. **Formula/Concept:** We use iterative pointer manipulation. Let $\text{prev} = \text{null}$, $\text{current} = \text{head}$.
3. **Step-by-step process:**
- While $\text{current} \neq \text{null}$:
- Save next node: $\text{next} = \text{current.next}$
- Reverse pointer: $\text{current.next} = \text{prev}$
- Move prev and current one step forward: $\text{prev} = \text{current}$, $\text{current} = \text{next}$
4. **Explanation:** We traverse the list once, reversing the direction of each pointer. At the end, $\text{prev}$ points to the new head of the reversed list.
5. **Final answer:** The reversed linked list head is $\text{prev}$ after the loop ends.
Reverse Linked List 7Dfbca
Step-by-step solutions with LaTeX - clean, fast, and student-friendly.