public static void Main(string[] args)
first.Push(2).Push(3).Push(4).Push(5);
Console.WriteLine("=============== After swapping ===============");
static void DeleteAlternate(Node first)
while (node?.Next?.Next != null)
node.Next = node.Next.Next;
if (node?.Next != null && node.Next.Next == null)
public int Data { get; set; }
public Node Next { get; set; }
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()