public void TestGMergeSingleNodesLargerSmaller()
        {
            LeftistTree <KeyValuePair <int, string> > t1     = new LeftistTree <KeyValuePair <int, string> >(new KeyValuePair <int, string>(2, "two"), null, null);
            LeftistTree <KeyValuePair <int, string> > t2     = new LeftistTree <KeyValuePair <int, string> >(new KeyValuePair <int, string>(5, "five"), null, null);
            LeftistTree <KeyValuePair <int, string> > result = MinPriorityQueue <int, string> .Merge(t2, t1);

            Assert.Multiple(() =>
            {
                Assert.That(result.Data, Is.EqualTo(t1.Data));
                Assert.That(result.LeftChild, Is.EqualTo(t2));
                Assert.That(result.RightChild, Is.Null);
            });
        }
        public void TestEThreeNodeShape()
        {
            int[]             children = { 3, 9 };
            LeftistTree <int> t        = new LeftistTree <int>(5, new LeftistTree <int>(children[0], null, null),
                                                               new LeftistTree <int>(children[1], null, null));

            int[] test = { t.LeftChild.Data, t.RightChild.Data };
            Assert.Multiple(() =>
            {
                Assert.That(t.Data, Is.EqualTo(5));
                Assert.That(test, Is.EquivalentTo(children));
            });
        }
Exemple #3
0
        public void TestHMergeGeneral()
        {
            LeftistTree <KeyValuePair <int, string> > t1Child1 = new LeftistTree <KeyValuePair <int, string> >(new KeyValuePair <int, string>(5, "five"), null, null);
            LeftistTree <KeyValuePair <int, string> > t1Child2 = new LeftistTree <KeyValuePair <int, string> >(new KeyValuePair <int, string>(6, "six"), null, null);
            LeftistTree <KeyValuePair <int, string> > t1       = new LeftistTree <KeyValuePair <int, string> >(new KeyValuePair <int, string>(2, "two"), t1Child1, t1Child2);
            LeftistTree <KeyValuePair <int, string> > t2       = new LeftistTree <KeyValuePair <int, string> >(new KeyValuePair <int, string>(4, "four"), null, null);
            LeftistTree <KeyValuePair <int, string> > result   = MinPriorityQueue <int, string> .Merge(t1, t2);

            List <KeyValuePair <int, string> > contents = new List <KeyValuePair <int, string> >();

            AddAll(result, contents);
            Assert.That(contents, Is.EquivalentTo(new KeyValuePair <int, string>[] { t1.Data, t1.LeftChild.Data, t1.RightChild.Data, t2.Data }));
        }
Exemple #4
0
 public void TestBSingleNodeNpl()
 {
     Assert.That(LeftistTree <int> .NullPathLength(new LeftistTree <int>(7, null, null)), Is.EqualTo(1));
 }
Exemple #5
0
 public void TestAEmptyNpl()
 {
     Assert.That(LeftistTree <string> .NullPathLength(null), Is.EqualTo(0));
 }
Exemple #6
0
        public void TestFMergeOneNodeAndEmpty()
        {
            LeftistTree <KeyValuePair <int, string> > t = new LeftistTree <KeyValuePair <int, string> >(new KeyValuePair <int, string>(2, "two"), null, null);

            Assert.That(MinPriorityQueue <int, string> .Merge(t, null), Is.EqualTo(t));
        }