public static void Main(string[] args)
var second = new Node(2);
var fourth = new Node(4);
Console.WriteLine("=============== After swapping ===============");
static void PairWiseSwap(ref Node head)
if (current != null && current.Next != null)
while (current != null && current.Next != null)
current.Next = next.Next;
Console.WriteLine(node.Data);
public int GetLengthIterative()
public int GetLengthRecursive()
return 1 + this.Next.GetLengthRecursive();
public override string ToString()