public static void Main(string[] args)
first.Push(2).Push(3).Push(4).Push(6);
var second = new Node(2);
second.Push(4).Push(6).Push(8);
var sorted = SortedIntersect(first, second);
Console.WriteLine("=============== After swapping ===============");
static Node SortedIntersect(Node first, Node second)
if (first == null || second == null)
if (first.Data > second.Data)
return SortedIntersect(first, second.Next);
if (second.Data > first.Data)
return SortedIntersect(first.Next, second);
var temp = new Node(first.Data);
temp.Next = SortedIntersect(first.Next, second.Next);
Console.Write(node.Data);
public int GetLengthIterative()
public int GetLengthRecursive()
return 1 + this.Next.GetLengthRecursive();
public Node Push(int data)
var node = new Node(data);
public override string ToString()