Since long back I have not used C or C++ ,so forget completely about Pointers. I'm familiar with C# and have written a basic version of this. Need to know whether I'm doing right/wrong?
Input:Linked List a->b->c->d->e->null
Output: Linked List b->a->d->c->e->null
We have to write code such that memory position is swapped and not the node value.
public void SwapLinkedList(LinkedList<int> LL)
{
LinkedListNode<int> current = LL.First;
while (current.Next != null)
{
int temp = current.Next.Value;
current.Next.Value = current.Value;
current.Value = temp;
current = current.Next.Next;
}
}