Swap alternate nodes in a singly linked list

Given a single Linked List. Swap every other alternate nodes.

For example, given 1–>2–>3–>4–>5–>null then output 3–>4–>5–>2–>1–>null. Note that, the list was transformed in several steps.

  1. First step, swap 1 and 3 i.e. 3–>2–>1–>4–>5–>null
  2. Second step, swap 2 and 4 i.e. 3–>4–>1–>2–>5–>null
  3. last step, swap 1 and 5, i.e. 3–>4–>5–>2–>1–>null