Example #1
0
        public void NoCycleLengthOne()
        {
            EPI.DataStructures.LinkedList.LinkedList <Object> list = new EPI.DataStructures.LinkedList.LinkedList <Object>();
            Node <Object> a = new Node <object>();

            list.Head = a;
            a.Next    = null;

            Assert.Null(C07Q03 <Object> .FindCycleWithDict(list));
            Assert.Null(C07Q03 <Object> .FindCycle(list));
            Assert.Null(C07Q03 <Object> .FindCycleOptimized(list));
        }
Example #2
0
        public void CycleStartsAtHeadLengthOne()
        {
            EPI.DataStructures.LinkedList.LinkedList <Object> list = new EPI.DataStructures.LinkedList.LinkedList <Object>();
            Node <Object> a = new Node <object>();

            list.Head = a;
            a.Next    = a;

            Assert.Equal(a, C07Q03 <Object> .FindCycleWithDict(list));
            Assert.Equal(a, C07Q03 <Object> .FindCycle(list));
            Assert.Equal(a, C07Q03 <Object> .FindCycleOptimized(list));
        }
Example #3
0
        public void HasCycle01()
        {
            EPI.DataStructures.LinkedList.LinkedList <Object> list = new EPI.DataStructures.LinkedList.LinkedList <Object>();
            Node <Object> a = new Node <object>();
            Node <Object> b = new Node <object>();
            Node <Object> c = new Node <object>();

            list.Head = a;
            a.Next    = b;
            b.Next    = c;
            c.Next    = b;

            Assert.Equal(b, C07Q03 <Object> .FindCycleWithDict(list));
            Assert.Equal(b, C07Q03 <Object> .FindCycle(list));
            Assert.Equal(b, C07Q03 <Object> .FindCycleOptimized(list));
        }
Example #4
0
        public void CycleAtTailLengthOne()
        {
            EPI.DataStructures.LinkedList.LinkedList <Object> list = new EPI.DataStructures.LinkedList.LinkedList <Object>();
            Node <Object> a = new Node <object>();
            Node <Object> b = new Node <object>();
            Node <Object> c = new Node <object>();
            Node <Object> d = new Node <object>();
            Node <Object> e = new Node <object>();
            Node <Object> f = new Node <object>();

            list.Head = a;
            a.Next    = b;
            b.Next    = c;
            c.Next    = d;
            d.Next    = e;
            e.Next    = f;
            f.Next    = f;

            Assert.Equal(f, C07Q03 <Object> .FindCycleWithDict(list));
            Assert.Equal(f, C07Q03 <Object> .FindCycle(list));
            Assert.Equal(f, C07Q03 <Object> .FindCycleOptimized(list));
        }