public static void Main(string[] args) { string[] inputs = { "1 2 5 x x x x x 3 x x x 4 x x x", "1 2 3 x x x 4 x x x 7 x x x 5 x x x 6 x x x" }; for (int i = 0; i < inputs.Length; i++) { Node root = null; int start = 0; root = Node.BuildTree(root, inputs[i].Split(" "), ref start); Console.WriteLine("Ternary tree paths : " + String.Join(',', TernaryTreePaths(root))); } }