public static IEnumerable <T> Traverse <T>(this T root, TraverseType traverseType) where T : ITreeNode <T> { switch (traverseType) { case TraverseType.PreOrder: return(root.PreOrderTraverse()); case TraverseType.Ancestors: return(root.AncestorsTraverse()); default: throw new NotSupportedException(traverseType.ToString()); } }
public override string ToString() => "BinaryTree: " + tree.ToString() + "\nTraverseTyp: " + traverseType.ToString();