Exemplo n.º 1
0
        public void ValidateBST()
        {
            AlgorithmPractice.Tree.Problems.TreeNode node = new AlgorithmPractice.Tree.Problems.TreeNode(0);

            node.left = new AlgorithmPractice.Tree.Problems.TreeNode(-1);

            validateBSTSol sol = new validateBSTSol();

            sol.IsValidBST(node);
        }
Exemplo n.º 2
0
 public void TestBinaryLevelOrderTraversal()
 {
     AlgorithmPractice.Tree.Problems.TreeNode node = new AlgorithmPractice.Tree.Problems.TreeNode(3);
     node.left        = new AlgorithmPractice.Tree.Problems.TreeNode(9);
     node.left.left   = new AlgorithmPractice.Tree.Problems.TreeNode(11);
     node.left.right  = new AlgorithmPractice.Tree.Problems.TreeNode(12);
     node.right       = new AlgorithmPractice.Tree.Problems.TreeNode(20);
     node.right.left  = new AlgorithmPractice.Tree.Problems.TreeNode(15);
     node.right.right = new AlgorithmPractice.Tree.Problems.TreeNode(7);
     PrintLevelOrderSolution sol = new PrintLevelOrderSolution();
     var output = sol.LevelOrder(node);
 }
Exemplo n.º 3
0
        public void TestDeserializeSerialize()
        {
            AlgorithmPractice.Tree.Problems.TreeNode node = new AlgorithmPractice.Tree.Problems.TreeNode(1);

            node.left       = new AlgorithmPractice.Tree.Problems.TreeNode(2);
            node.right      = new AlgorithmPractice.Tree.Problems.TreeNode(3);
            node.right.left = new AlgorithmPractice.Tree.Problems.TreeNode(4);

            node.right.right = new AlgorithmPractice.Tree.Problems.TreeNode(5);

            Codec cd               = new Codec();
            var   output           = cd.Serialize(node);
            var   deserializedNode = cd.Deserialize(output);
        }