Start from head and initialize curr = head. Traverse while curr != NULL and curr->next != NULL.
Swap data of current pair (curr->data <-> curr->next->data).
Move to the next pair using curr = curr->next->next.
Stop when no pair remains
Output
2 -> 1 -> 4 -> 3 -> 6 -> 5
Changing Links - O(n) Time and O(1) Space
Instead of swapping the data inside nodes, we change the links (pointers) between nodes. This avoids heavy data movement, especially when nodes store complex objects (like student records).
We keep track of the previous node while traversing and change next of current to previous. We need ensure that proper pointers are set before the next iteration of the loop.