Beispiel #1
0
        public void SameHead()
        {
            EPI.DataStructures.LinkedList.LinkedList <Object> listA = new EPI.DataStructures.LinkedList.LinkedList <Object>();
            EPI.DataStructures.LinkedList.LinkedList <Object> listB = new EPI.DataStructures.LinkedList.LinkedList <Object>();
            Node <Object> aa = new Node <object>();
            Node <Object> ab = new Node <object>();
            Node <Object> ac = new Node <object>();

            listA.Head = aa;
            listB.Head = aa;
            aa.Next    = ab;
            ab.Next    = ac;
            ac.Next    = null;

            Assert.Equal(aa, C07Q04 <Object> .FindOverlapWithHash(listA, listB));
            Assert.Equal(aa, C07Q04 <Object> .FindOverlapBruteForce(listA, listB));
            Assert.Equal(aa, C07Q04 <Object> .FindOverlap(listA, listB));
        }
Beispiel #2
0
        public void NoOverlap()
        {
            EPI.DataStructures.LinkedList.LinkedList <Object> listA = new EPI.DataStructures.LinkedList.LinkedList <Object>();
            EPI.DataStructures.LinkedList.LinkedList <Object> listB = new EPI.DataStructures.LinkedList.LinkedList <Object>();
            Node <Object> aa = new Node <object>();
            Node <Object> ab = new Node <object>();
            Node <Object> ba = new Node <object>();
            Node <Object> bb = new Node <object>();
            Node <Object> bc = new Node <object>();
            Node <Object> bd = new Node <object>();

            listA.Head = aa;
            aa.Next    = ab;
            ab.Next    = null;
            listB.Head = ba;
            ba.Next    = bb;
            bb.Next    = bc;
            bc.Next    = bd;
            bd.Next    = null;

            Assert.Null(C07Q04 <Object> .FindOverlapWithHash(listA, listB));
            Assert.Null(C07Q04 <Object> .FindOverlapBruteForce(listA, listB));
            Assert.Null(C07Q04 <Object> .FindOverlap(listA, listB));
        }