public void ShowPost(BinNode <t> node) { if (node != null) { ShowPost(node.GetLeft()); ShowPost(node.GetRight()); MessageBox.Show(node.GetValue() + " "); } }
public bool IsAllPos(BinNode <int> node) { if (node == null) { return(true); } if (node.GetValue() <= 0) { return(false); } return(IsAllPos(node.GetLeft()) && IsAllPos(node.GetRight())); }
public double Result(BinNode <string> node, double x, double y) { if (node == null) { return(0); } if (node.GetValue() == "+") { return(Result(node.GetLeft(), x, y) + Result(node.GetRight(), x, y)); } if (node.GetValue() == "-") { return(Result(node.GetLeft(), x, y) - Result(node.GetRight(), x, y)); } if (node.GetValue() == "*") { return(Result(node.GetLeft(), x, y) * Result(node.GetRight(), x, y)); } if (node.GetValue() == "/") { return(Result(node.GetLeft(), x, y) / Result(node.GetRight(), x, y)); } if (node.GetValue() == "^") { return(Math.Pow(Result(node.GetLeft(), x, y), Result(node.GetRight(), x, y))); } if (node.GetValue() == "sin") { return(Math.Sin(Result(node.GetLeft(), x, y))); } if (node.GetValue() == "cos") { return(Math.Cos(Result(node.GetLeft(), x, y))); } if (node.GetValue() == "tan") { return(Math.Tan(Result(node.GetLeft(), x, y))); } if (node.GetValue() == "sqrt") { return(Math.Sqrt(Result(node.GetLeft(), x, y))); } if (node.GetValue() == "x") { return(x); } if (node.GetValue() == "y") { return(y); } return(double.Parse(node.GetValue())); }