Ejemplo n.º 1
0
 public void CornerCases(InOrderDelegate traverseFunc)
 {
     Assert.AreEqual(new List <int>(), traverseFunc(null));
     Assert.AreEqual(new List <int> {
         3
     }, traverseFunc(new InOrderTraversal.TreeNode(3)));
 }
Ejemplo n.º 2
0
        public void RightTreeOnly(InOrderDelegate traverseFunc)
        {
            var r = new InOrderTraversal.TreeNode(1);

            r.right             = new InOrderTraversal.TreeNode(2);
            r.right.right       = new InOrderTraversal.TreeNode(3);
            r.right.right.right = new InOrderTraversal.TreeNode(4);
            Assert.AreEqual(new List <int> {
                1, 2, 3, 4
            }, traverseFunc(r));
        }
Ejemplo n.º 3
0
        public void LeftTreeOnly(InOrderDelegate traverseFunc)
        {
            var r = new InOrderTraversal.TreeNode(1);

            r.left           = new InOrderTraversal.TreeNode(2);
            r.left.left      = new InOrderTraversal.TreeNode(3);
            r.left.left.left = new InOrderTraversal.TreeNode(4);
            Assert.AreEqual(new List <int> {
                4, 3, 2, 1
            }, traverseFunc(r));
        }
Ejemplo n.º 4
0
        public void NormalTree(InOrderDelegate traverseFunc)
        {
            var r = new InOrderTraversal.TreeNode(1);

            r.left        = new InOrderTraversal.TreeNode(2);
            r.right       = new InOrderTraversal.TreeNode(3);
            r.left.left   = new InOrderTraversal.TreeNode(4);
            r.left.right  = new InOrderTraversal.TreeNode(5);
            r.right.left  = new InOrderTraversal.TreeNode(6);
            r.right.right = new InOrderTraversal.TreeNode(7);
            Assert.AreEqual(new List <int> {
                4, 2, 5, 1, 6, 3, 7
            }, traverseFunc(r));
        }