/// <summary> /// Recursive helper method for pre-order traversal. Should not be called directly /// </summary> /// <param name="current">The current node being traversed</param> /// <param name="list">The list of values to be added to</param> public void PreOrderTraversal(StringNode current, List <string> list) { //add current, then go to left, then to right list.Add(current.Value); if (current.Left != null) { PreOrderTraversal(current.Left, list); } if (current.Right != null) { PreOrderTraversal(current.Right, list); } }
public void FizzBuzzRecursive(IntNode intNode, StringNode stringNode) { if (intNode.Left != null) { stringNode.Left = new StringNode(FizzBuzz(intNode.Left.Value)); FizzBuzzRecursive(intNode.Left, stringNode.Left); } else if (intNode.Right != null) { stringNode.Right = new StringNode(FizzBuzz(intNode.Right.Value)); FizzBuzzRecursive(intNode.Right, stringNode.Right); } }
public StringNode(string val) { Value = val; Left = null; Right = null; }
public BinaryStringTree() { Root = null; }