Ejemplo n.º 1
0
        public void Test2()
        {
            var four = new FNode(4);

            four.Head      = new FNode(5);
            four.Head.Next = new FNode(6);

            var one = new FNode(1);

            one.Head      = new FNode(3);
            one.Head.Next = new FNode(7);

            var nine = new FNode(9);

            nine.Head      = new FNode(11);
            nine.Head.Next = new FNode(13);

            four.Next = one;
            one.Next  = nine;

            var expected = new int[] { 1, 3, 4, 5, 6, 7, 9, 11, 13 };
            var fl       = new FlattenLists();
            var result   = fl.Flatten(four);

            var actual = AlgoUtilities.Utilities.ToList(result);

            var equal = actual.SequenceEqual(expected);

            Assert.That(equal, Is.True);
        }
Ejemplo n.º 2
0
        public void Test1()
        {
            var five = new FNode(5);

            five.Head           = new FNode(7);
            five.Head.Next      = new FNode(8);
            five.Head.Next.Next = new FNode(30);

            var ten = new FNode(10);

            ten.Head = new FNode(20);

            five.Next = ten;

            var expected = new int[] { 5, 7, 8, 10, 20, 30 };
            var fl       = new FlattenLists();
            var result   = fl.Flatten(five);

            var actual = AlgoUtilities.Utilities.ToList(result);

            var equal = actual.SequenceEqual(expected);

            Assert.That(equal, Is.True);
        }