예제 #1
0
        public void RootIsLca()
        {
            var x   = exampleTree.Find(13);
            var y   = exampleTree.Find(41);
            var lca = exampleTree.Find(19);

            Assert.Equal(lca, Q04 <int> .FindLowestCommonAncestor(exampleTree, x, y));
        }
예제 #2
0
        public void BiggerNodeIsLca()
        {
            var x   = exampleTree.Find(31);
            var y   = exampleTree.Find(43);
            var lca = exampleTree.Find(43);

            Assert.Equal(lca, Q04 <int> .FindLowestCommonAncestor(exampleTree, x, y));
        }
예제 #3
0
        public void Example()
        {
            var nodeC = exampleTree.Find(3);
            var nodeG = exampleTree.Find(17);
            var lca   = exampleTree.Find(7);

            Assert.Equal(3, nodeC.Value);
            Assert.Equal(17, nodeG.Value);
            Assert.Equal(7, lca.Value);

            Assert.Equal(lca, Q04 <int> .FindLowestCommonAncestor(exampleTree, nodeC, nodeG));
        }