Linked List – Compare Lists
public bool IsEqual(LinkedList<T> l)
{
Node<T> current1 = head;
Node<T> current2 = l.head;
while ((current1 != null) && (current2 != null))
{
if (current1.Data.CompareTo(current2.Data) != 0)
return false;
current1 = current1.Next;
current2 = current2.Next;
}
/
/check if both lists ended at the same time
if ((current1 == null) && (current2 == null))
return true;
else
return false;
}