コード例 #1
0
        public void Test4()
        {
            var list = AlgoUtilities.Utilities.ToSingleLinkedList(new int[] { 1 });

            var sut    = new DetectLoopInLinkedList();
            var result = sut.HasLoop(list);

            Assert.IsFalse(result);
        }
コード例 #2
0
        public void Test1()
        {
            var list = AlgoUtilities.Utilities.ToSingleLinkedList(new int[] { 1, 2, 3, 4, 5 });
            var last = AlgoUtilities.Utilities.FindLastNode(list);

            // Create a loop
            last.Next = list.Next;

            var sut    = new DetectLoopInLinkedList();
            var result = sut.HasLoop(list);

            Assert.IsTrue(result);
        }