Ejemplo n.º 1
0
 internal BinaryTree(IBinaryTreeNode <T> root, int nodeCount, int depth, BinaryTreeType type)
 {
     Root      = root;
     NodeCount = nodeCount;
     Depth     = depth;
     Type      = type;
 }
Ejemplo n.º 2
0
        public IBinaryTree <T> BuildTree(List <T> nodeValues, BinaryTreeType type)
        {
            if (nodeValues == null || nodeValues.Count == 0)
            {
                return(null);
            }
            var nodes = new List <IBinaryTreeNode <T> >();
            var depth = 0;

            foreach (var value in nodeValues)
            {
                nodes.Add(_nodeProvider.GetBinaryTreeNode(value));
            }
            IBinaryTreeNode <T> root = null;

            switch (type)
            {
            case BinaryTreeType.Complete:
            {
                root = BuildCompleteTree(nodes);
                break;
            }

            case BinaryTreeType.Search:
            {
                root = BuildSearchTree(nodes);
                break;
            }
            }
            root.Type = BinaryTreeNodeType.Root;
            GetDepth(root, ref depth);
            return(new BinaryTree <T>(root, nodes.Count, depth, type));
        }
Ejemplo n.º 3
0
 public MovieBinaryTreeRepo(BinaryTreeType treeType)
 {
     TreeType = treeType;
 }
Ejemplo n.º 4
0
 private void GivenTree(List <int> nodes, BinaryTreeType type)
 {
     _tree = _structureBuilder.BuildTree(nodes, type);
 }