public void Reverse() { var linkedList = new Structures.LinkedList <int>(); linkedList.Insert(2); linkedList.Insert(3); linkedList.Insert(4); linkedList.Insert(5); linkedList.Reverse(); linkedList.Iterate(c => Console.WriteLine(c.Value)); }
public void MiddleNode() { var linkedList = new Structures.LinkedList <int>(); linkedList.Insert(1); linkedList.Insert(2); linkedList.Insert(3); linkedList.Insert(4); linkedList.Insert(5); ListNode <int> mid = linkedList.Middle(); Assert.AreEqual(3, mid.Value); }
public void RemoveDuplicates() { var linkedList = new Structures.LinkedList <int>(); linkedList.Insert(5); linkedList.Insert(5); linkedList.Insert(5); linkedList.Insert(5); linkedList.RemoveDuplicatesNoAux(); linkedList.Iterate(c => Console.WriteLine(c.Value)); }
public void ReverseNoRecursion() { var linkedList = new Structures.LinkedList <int>(); linkedList.Insert(2); linkedList.Insert(3); linkedList.Insert(4); linkedList.Insert(5); Printer.Print(linkedList); linkedList.ReverseNoRecursion(); Printer.Print(linkedList); }
public void FindLoop() { var linkedList = new Structures.LinkedList <int>(); linkedList.Insert(2); linkedList.Insert(3); linkedList.Insert(4); linkedList.Insert(5); linkedList.Insert(10); linkedList.Insert(12); linkedList.Insert(13); linkedList.Insert(14); linkedList.Insert(20); linkedList.Insert(30); ListNode <int> fail = linkedList.Find(13); fail.Next = fail; ListNode <int> loop = FindLoopNode(linkedList); Assert.AreEqual(fail.Value, loop.Value); }