public static void Main(String[] args) { Tree <int> t = MakeTree(1, 15); Act <int> act = delegate(int val) { Console.Write("{0} ", val); }; Console.WriteLine("Depth-first:"); Tree <int> .DepthFirst(t, act); Console.WriteLine("\nBreadth-first:"); Tree <int> .BreadthFirst(t, act); Console.WriteLine("\nDepth-first:"); Tree <int> .Traverse(t, act, new ArrayList <Tree <int> >()); Console.WriteLine("\nBreadth-first:"); Tree <int> .Traverse(t, act, new LinkedList <Tree <int> >()); Console.WriteLine(); }
public static void Main(String[] args) { Tree <int> t = MakeTree(1, 15); void action(int val) => Console.Write("{0} ", val); Console.WriteLine("Depth-first:"); Tree <int> .DepthFirst(t, action); Console.WriteLine("\nBreadth-first:"); Tree <int> .BreadthFirst(t, action); Console.WriteLine("\nDepth-first:"); Tree <int> .Traverse(t, action, new ArrayList <Tree <int> >()); Console.WriteLine("\nBreadth-first:"); Tree <int> .Traverse(t, action, new LinkedList <Tree <int> >()); Console.WriteLine(); }