internal BinaryTree(IBinaryTreeNode <T> root, int nodeCount, int depth, BinaryTreeType type) { Root = root; NodeCount = nodeCount; Depth = depth; Type = type; }
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)); }
public MovieBinaryTreeRepo(BinaryTreeType treeType) { TreeType = treeType; }
private void GivenTree(List <int> nodes, BinaryTreeType type) { _tree = _structureBuilder.BuildTree(nodes, type); }